-
Notifications
You must be signed in to change notification settings - Fork 24
MULTIARCH-3667: Loadbalancer integration support for control plane machines #41
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
MULTIARCH-3667: Loadbalancer integration support for control plane machines #41
Conversation
|
@Prajyot-Parab @dharaneeshvrd Please take a look and provide your feedback. |
| } | ||
| if !alreadyRegistered { | ||
| // make sure that LoadBalancer is in active state | ||
| loadBalancer, _, err := powerVSClient.GetLoadBalancer(&vpcv1.GetLoadBalancerOptions{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need another Get call here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In our case a loadbalancer will have 2 pools, So after updating one pool, if we try to update second one it will fail as the loadbalancer wont be in active state, so instead of throwing ugly error added a check.
pkg/actuators/machine/reconciler.go
Outdated
| klog.Infof("Deleting IP %s from LoadBalancer %s ", internalIP, lbName) | ||
|
|
||
| // Fetch the LoadBalancer details | ||
| loadBalancer, _, err := powerVSClient.GetLoadBalancer(&vpcv1.GetLoadBalancerOptions{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as previous comment
|
@dharaneeshvrd @Prajyot-Parab Please take a look when you get a chance, If the approach looks good I will go ahead and fix CI errors and add UT. |
pkg/actuators/machine/reconciler.go
Outdated
|
|
||
| internalIP := r.getMachineInternalIP() | ||
| if internalIP != "" { | ||
| klog.Infof("deregister ip %s of machine %s form LoadBalancer", internalIP, r.machine.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor Nit:
| klog.Infof("deregister ip %s of machine %s form LoadBalancer", internalIP, r.machine.Name) | |
| klog.Infof("deregister ip %s of machine %s from LoadBalancer", internalIP, r.machine.Name) |
JoelSpeed
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any feedback here apart from styling nits, I'd suggested always wrapping errors with additional context where possible, it tends to help with the flow of errors when debugging IMO, I'll leave the call to this repos maintainers though
pkg/actuators/machine/reconciler.go
Outdated
| internalIP := r.getMachineInternalIP() | ||
| if internalIP != "" { | ||
| klog.Infof("deregister ip %s of machine %s form LoadBalancer", internalIP, r.machine.Name) | ||
| if err = r.removeFromApplicationLoadBalancers(internalIP); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: no need to shadow the err var when you do this inline if style
| if err = r.removeFromApplicationLoadBalancers(internalIP); err != nil { | |
| if err := r.removeFromApplicationLoadBalancers(internalIP); err != nil { |
pkg/actuators/machine/reconciler.go
Outdated
| err := registerWithApplicationLoadBalancers(r.powerVSClient, applicationLoadBalancerNames, internalIP) | ||
| if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: should inline this
| err := registerWithApplicationLoadBalancers(r.powerVSClient, applicationLoadBalancerNames, internalIP) | |
| if err != nil { | |
| if err := registerWithApplicationLoadBalancers(r.powerVSClient, applicationLoadBalancerNames, internalIP); err != nil { |
pkg/actuators/machine/reconciler.go
Outdated
| err := registerWithApplicationLoadBalancers(r.powerVSClient, applicationLoadBalancerNames, internalIP) | ||
| if err != nil { | ||
| klog.Errorf("%s: Failed to register application load balancers: %v", r.machine.Name, err) | ||
| return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should wrap this error with additional context before returning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Karthik-K-N please take care of this comment..
pkg/actuators/machine/reconciler.go
Outdated
| func registerWithApplicationLoadBalancers(powerVSClient client.Client, loadBalancerNames []string, internalIP string) error { | ||
| lbMap, err := getLoadBalancers(powerVSClient, loadBalancerNames) | ||
| if err != nil { | ||
| return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should wrap this error with additional context before returning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
pkg/actuators/machine/reconciler.go
Outdated
| } | ||
|
|
||
| if err := utils.PagingHelper(f); err != nil { | ||
| return nil, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should wrap the error
pkg/actuators/machine/reconciler.go
Outdated
| } | ||
|
|
||
| if loadBalancersList == nil { | ||
| return nil, fmt.Errorf("no loadbalancer is retrieved") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No format string here
| return nil, fmt.Errorf("no loadbalancer is retrieved") | |
| return nil, errors.New("no loadbalancer is retrieved") |
pkg/actuators/machine/reconciler.go
Outdated
| ID: &lbOptions.id, | ||
| }) | ||
| if err != nil { | ||
| return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add context
pkg/actuators/machine/reconciler.go
Outdated
| }) | ||
| response, _, err := powerVSClient.CreateLoadBalancerPoolMember(options) | ||
| if err != nil { | ||
| return errors.Wrapf(err, "error creating LoadBalacner pool member") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use fmt.Errorf for consistency with the rest of this PR
Agree, @Karthik-K-N lets fix this wherever possible as a separate PR. |
2bc3202 to
24d105c
Compare
pkg/actuators/machine/reconciler.go
Outdated
| } | ||
| } | ||
| if len(lbMap) != len(loadBalancerNames) { | ||
| return nil, fmt.Errorf("not able to find %s loadbalancer in cloud", loadBalancerNames) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a possibility that this will have load balancers that are exist too in case of more than one load balancer is on search.
dharaneeshvrd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me!
Prajyot-Parab
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
pkg/client/powervs_client.go
Outdated
| c.ImageClient = instance.NewIBMPIImageClient(ctx, c.session, cloudInstanceID) | ||
| c.DHCPClient = instance.NewIBMPIDhcpClient(ctx, c.session, cloudInstanceID) | ||
|
|
||
| vpcZone, err := utils.VPCRegionForPowerVSRegion(c.region) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be a region
| vpcZone, err := utils.VPCRegionForPowerVSRegion(c.region) | |
| vpcRegion, err := utils.VPCRegionForPowerVSRegion(c.region) |
go.mod
Outdated
| require ( | ||
| github.com/IBM/vpc-go-sdk v0.35.0 | ||
| github.com/onsi/ginkgo/v2 v2.8.1 | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason for creating a different block? if not - can this be merged with above block?
pkg/actuators/machine/reconciler.go
Outdated
| err := registerWithApplicationLoadBalancers(r.powerVSClient, applicationLoadBalancerNames, internalIP) | ||
| if err != nil { | ||
| klog.Errorf("%s: Failed to register application load balancers: %v", r.machine.Name, err) | ||
| return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Karthik-K-N please take care of this comment..
pkg/actuators/machine/reconciler.go
Outdated
| func registerWithApplicationLoadBalancers(powerVSClient client.Client, loadBalancerNames []string, internalIP string) error { | ||
| lbMap, err := getLoadBalancers(powerVSClient, loadBalancerNames) | ||
| if err != nil { | ||
| return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
24d105c to
7f36f86
Compare
|
@Karthik-K-N Just wanted to check if you need any additional assistance or review here from me |
Thank you, I tried to address all the review comments and its ready for next round of review. |
|
General structure LGTM, will defer to @mkumatag to apply the label when they're happy with this |
|
@Karthik-K-N overall lgtm, can you squash the commits and split into, one for go mods and another for code changes? |
046fe75 to
a642495
Compare
|
@Karthik-K-N but I see Add loadbalancer pool logic contains the go mod and the vendor files.
|
a642495 to
c3d71ca
Compare
|
/lgtm @Karthik-K-N lets create a jira ticket if doesn't exist and map to this issue |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Karthik-K-N, mkumatag The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@Karthik-K-N: This pull request references MULTIARCH-3667 which is a valid jira issue. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
@Karthik-K-N: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |

With the introduction of cluster-control-plane-machine-set-operator(CPMS operator) now we can replace the control-plane machines in openshift cluster.
Control-plance machines will be attached to two loadbalancer in case of public cluster during the cluster creation and it will be done by the installer component.
When there is change in cpms object, the cpms operator will trigger machine replacement and during this time we need to update the loadbalancer with newly created vm ip and remove the ip of machine that is going to be deleted.
The sample control-plane machine object looks like this
Proposed api changes: openshift/api#1415
Pending work