Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[occm] ensure octavia monitor is always updated #2373

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

kayrus
Copy link
Contributor

@kayrus kayrus commented Sep 28, 2023

What this PR does / why we need it:

The PR reconciles reconciles health monitors on cluster scale up/down events.
The fix also improves the readability of the ensureOctaviaHealthMonitor method and now reconciles the monitor name as well.

Which issue this PR fixes(if applicable):

fixes #2370

Special notes for reviewers:

Release note:

[occm] Ensure Octavia health monitors are updated on `UpdateLoadBalancer` k8s service controller call.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 28, 2023
@kayrus kayrus requested a review from dulek September 28, 2023 10:24
@kayrus kayrus requested a review from mdbooth September 28, 2023 10:24
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 28, 2023
@kayrus kayrus force-pushed the octavia-ensure-monitor branch from fa4be3c to 63aa237 Compare September 28, 2023 14:12
@kayrus
Copy link
Contributor Author

kayrus commented Sep 28, 2023

/test openstack-cloud-csi-manila-sanity-test

@kayrus kayrus force-pushed the octavia-ensure-monitor branch from 63aa237 to 279a66f Compare September 28, 2023 15:08
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 1, 2023
@kayrus kayrus force-pushed the octavia-ensure-monitor branch from 279a66f to dd4b681 Compare October 2, 2023 09:12
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 2, 2023
@kayrus kayrus force-pushed the octavia-ensure-monitor branch from dd4b681 to 699065f Compare October 2, 2023 09:41
@kayrus
Copy link
Contributor Author

kayrus commented Oct 2, 2023

cc @mdbooth @dulek @jichenjc @zetaab

@dulek
Copy link
Contributor

dulek commented Oct 4, 2023

/approve

Question inline.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dulek

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 4, 2023
@kayrus
Copy link
Contributor Author

kayrus commented Oct 4, 2023

Question inline

@dulek what do you mean?

@kayrus
Copy link
Contributor Author

kayrus commented Oct 5, 2023

@mdbooth @dulek @jichenjc @zetaab kindly ping

Comment on lines +1075 to +1082
createOpts := lbaas.buildMonitorCreateOpts(svcConf, port, name)
if createOpts.Type != monitor.Type {
klog.InfoS("Recreating health monitor for the pool", "pool", pool.ID, "oldMonitor", monitorID)
if err := openstackutil.DeleteHealthMonitor(lbaas.lb, monitorID, lbID); err != nil {
return err
}
return lbaas.createOctaviaHealthMonitor(createOpts, pool.ID, lbID)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like you should be able to have just one line doing DeleteHealthMonitor() and one line doing createOctaviaHealthMonitor() to make it even more clean, but maybe you've already tried this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to check whether there is no error on the DeleteHealthMonitor stage before continuing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/dulek/cloud-provider-openstack/blob/octavia-ensure-monitor/pkg/openstack/loadbalancer.go#L1046-L1096

I've crafted something like this, haven't tested it. This seems to be quite closer to the previous version of the code, so I guess I liked it more.

The point here is that it makes sure there's only one place we call DeleteHealthMonitor() and createOctaviaHealthMonitor() from, which seems easier to maintain to me.

Copy link
Contributor Author

@kayrus kayrus Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this construction. I prefer to follow the https://medium.com/swlh/return-early-pattern-3d18a41bba8
For new users this code will be more readable and easy to understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dulek In addition, your logic doesn't cover a case, when a monitor must be recreated. You're deleting an old monitor without creating a new one. I think this is a good example on why long if blocks can confuse developers.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the DeleteOctaviaMonitor() should return there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dulek From my point of view the ensureOctaviaHealthMonitor method must re-create the monitor in case when its type cannot be changed. The logic that you propose, just deletes an old monitor (DeleteOctaviaMonitor()) and a new monitor is created only on the next reconciliation loop.

@kayrus
Copy link
Contributor Author

kayrus commented Oct 9, 2023

@mdbooth @dulek @jichenjc @zetaab kindly ping

@jichenjc
Copy link
Contributor

/lgtm
/hold

I am good with the change, leave a hold here so after solve above comments from @dulek we can unhold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 10, 2023
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 10, 2023
@dulek
Copy link
Contributor

dulek commented Oct 10, 2023

/lgtm
/hold cancel

Okay, I've read this again, the diff is awful, the code is actually really easy to follow

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 10, 2023
@kayrus
Copy link
Contributor Author

kayrus commented Oct 10, 2023

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[occm] loadbalancer health monitor is not reconciled when cluster nodes are scaled up/down
4 participants