-
Notifications
You must be signed in to change notification settings - Fork 431
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
🐛 Skip InboundNatRule reconciliation if no LB is configured #2066
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,9 +56,19 @@ func New(scope InboundNatScope) *Service { | |
|
||
// Reconcile gets/creates/updates an inbound NAT rule. | ||
func (s *Service) Reconcile(ctx context.Context) error { | ||
ctx, _, done := tele.StartSpanWithLogger(ctx, "inboundnatrules.Service.Reconcile") | ||
ctx, log, done := tele.StartSpanWithLogger(ctx, "inboundnatrules.Service.Reconcile") | ||
defer done() | ||
|
||
// Externally managed clusters might not have an LB | ||
if s.Scope.APIServerLBName() == "" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you please also add a comment that explains this is to support the externally managed use case? I could see someone else reading the code later and having the exact same reaction as Jack did above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a comment, let me know what you think |
||
log.V(4).Info("Skipping InboundNatRule reconciliation as the cluster has no LB configured") | ||
// Until https://github.com/kubernetes-sigs/cluster-api-provider-azure/issues/1868 is | ||
// resolved, this needs to be set for the machine to be able to reach the ready condition: | ||
// https://github.com/kubernetes-sigs/cluster-api-provider-azure/pull/2066#discussion_r806150004 | ||
s.Scope.UpdatePutStatus(infrav1.InboundNATRulesReadyCondition, serviceName, nil) | ||
return nil | ||
} | ||
|
||
ctx, cancel := context.WithTimeout(ctx, reconciler.DefaultAzureServiceReconcileTimeout) | ||
defer cancel() | ||
|
||
|
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.
How is it possible to create a cluster without a apiserver load balancer? In other words, how does the above condition (empty string value for
AzureCluster.Spec.NetworkSpec.APIServerLB.Name
) ever occur?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.
@jackfrancis as mentioned in the PR description, this can happen if the cluster is managed externally, see https://capz.sigs.k8s.io/topics/externally-managed-azure-infrastructure.html
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.
Thanks. The code lgtm. I am a bit confused about this line in the docs:
If reconciliation is skipped, then why is this change needed?
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.
The cluster controllers skips reconciling it, however the azuremachine-related controllers still do:
cluster-api-provider-azure/controllers/azuremachine_reconciler.go
Lines 90 to 92 in a42074c
We want to use capz to only manage worker machines, which is how we ran into this.
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.
cc @Jont828
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.
@Jont828 we were talking offline yesterday about your wanting this scenario to
s.Scope.UpdatePutStatus
even if it's a no-op (no LB present). Can you explain why?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 thought about that, but it seemed to me that setting an InboundNATRulesReadyCondition will lead to confusion, because we have to set it to
false
which makes it look like there is an issue but there isn't. Happy to be convinced otherwise though.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.
Agree that setting the condition when there is no resource is confusing which is why we have #1868 open to address that. However in the meantime we need to set all conditions that are defined in https://github.com/kubernetes-sigs/cluster-api-provider-azure/blob/main/azure/scope/machine.go#L550 to true otherwise the AzureMachine won't reach Ready condition as summary will include false conditions. However in this case it looks like
InboundNATRulesReadyCondition
is missing from the list of summary conditions (potentially a bug?).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 see, updated the change to do the
UpdatePutStatus
even when there is no LB