-
Notifications
You must be signed in to change notification settings - Fork 423
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
Fix custom backendPool not being used #3676
Fix custom backendPool not being used #3676
Conversation
Welcome @RadekManak! |
Hi @RadekManak. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
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 didn't review the changes on *_mock.go
, putting it to later since I had some implementation questions.
func (s *ClusterScope) APIServerLBPoolName(loadBalancerName string) string { | ||
return azure.GenerateBackendAddressPoolName(loadBalancerName) | ||
func (s *ClusterScope) APIServerLBPoolName() string { | ||
return s.APIServerLB().BackendPool.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.
Is it possible that s.APIServerLB()
to be nil
? If so, can we run into nil pointer dereference ?
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.
Also, do you think it is valid to use azure.GenerateBackendAddressPoolName(loadBalancerName)
as a backup name if s.APIServerLB().BackendPool.Name
is 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.
Is it possible that s.APIServerLB() to be nil? If so, can we run into nil pointer dereference ?
It cannot be nil. A function above is creating the pointer from a struct field.
// APIServerLB returns the cluster API Server load balancer.
func (s *ClusterScope) APIServerLB() *infrav1.LoadBalancerSpec {
return &s.AzureCluster.Spec.NetworkSpec.APIServerLB
}
azure.GenerateBackendAddressPoolName(loadBalancerName)
is a valid default name for the backendPool, but it is already being set by the defaulting webhook if it is empty. I don't believe that adding the defaulting here as well has any benefit.
azure/scope/cluster.go
Outdated
// OutboundLBName returns the name of the outbound LB. | ||
func (s *ClusterScope) OutboundLBName(role string) string { | ||
// OutboundLB returns the outbound LB. | ||
func (s *ClusterScope) OutboundLB(role string) *infrav1.LoadBalancerSpec { |
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.
- Are we using
OutboundLB()
anywhere else outside this package? Any specific reason on exporting it out?
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.
- If it's just the
lb.Name
we are interested in, can we just return the name instead of the whole spec?
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.
You're right should be private. I have decomposed the load balancer selection logic into a function because it is needed in both OutboundLBName and OutboundPoolName.
In some places the default backendPool name was being used instead of the specified value.
f947836
to
cb94940
Compare
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.
/ok-to-test
@RadekManak: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed 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.
/lgtm
/assign @nawazkh
/milestone v1.10
LGTM label has been added. Git tree hash: ad701eb14f834c9085128f6eb6d25b6b2d905fc5
|
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #3676 +/- ##
==========================================
+ Coverage 53.74% 53.98% +0.24%
==========================================
Files 185 185
Lines 18595 18699 +104
==========================================
+ Hits 9994 10095 +101
- Misses 8059 8061 +2
- Partials 542 543 +1
☔ View full report in Codecov by Sentry. |
pull-cluster-api-provider-azure-apidiff test seems to be failing since we are changing the interface in here. Does it classify as a breaking change? Do we need to take care of any more stuff? Maybe call out in the Release Notes? |
Looks good to me.
/lgtm |
thanks for calling that out. In this case we should be fine since it's only touching the scope functions which we don't make guarantees on (breaking changes in the user-facing API is what we want to watch out for). That being said, we should really move code that isn't meant to be consumed as a library to an internal/ directory to avoid these false positives. |
/approve Let's cherry-pick this one since it fixes a bug ^ |
@CecileRobertMichon: once the present PR merges, I will cherry-pick it on top of release-1.9 in a new PR and assign it to you. In 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. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CecileRobertMichon 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 |
@CecileRobertMichon: new pull request created: #3690 In 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. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
In some places the default backendPool name was being used instead of using the specified value. This caused machine creation to fail when attempting to use loadBalancer with custom backendPool name.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
TODOs:
Release note: