🐛 Return errors from HasKubeadmConfig instead of swallowing them - #14067
Open
mrueg wants to merge 1 commit into
Open
🐛 Return errors from HasKubeadmConfig instead of swallowing them#14067mrueg wants to merge 1 commit into
mrueg wants to merge 1 commit into
Conversation
|
|
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
HasKubeadmConfig discarded every error returned by the API server and
reported it as "the cluster does not have a kubeadm-config ConfigMap":
err := w.Client.Get(ctx, key, &corev1.ConfigMap{})
return err == nil, nil
A request timeout, an RBAC denial or a transient workload cluster
apiserver outage was therefore indistinguishable from the ConfigMap
genuinely being absent. Both callers in the KubeadmControlPlane status
reconciler check the returned error, so those checks could never fire.
As a result a transient failure to reach the workload cluster made KCP
conclude the control plane was not initialized, so it left
status.initialization.controlPlaneInitialized and the Available condition
unset and waited for the next resync rather than surfacing the failure
and retrying.
Only NotFound now maps to false; any other error is returned to the
caller, which makes the existing error handling in the two callers
effective.
Also adds a test case covering a non-NotFound error, using
interceptor.NewClient to inject it. The existing expectErr field in the
test table was previously unused.
Signed-off-by: Manuel Rüger <[email protected]>
mrueg
force-pushed
the
fix/kcp-haskubeadmconfig-error-handling
branch
from
August 11, 2026 20:57
f08ec86 to
6e53179
Compare
Member
|
Same comment as here: #13960 What is the issue with this code that we are suddenly getting PRs to change it? Please also consider https://www.kubernetes.dev/docs/guide/pull-requests/#ai-guidance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
HasKubeadmConfigdiscarded every error returned by the API server and reported it as "the cluster does not have a kubeadm-config ConfigMap":A request timeout, an RBAC denial or a transient workload cluster apiserver outage was therefore indistinguishable from the ConfigMap genuinely being absent.
Both callers, in
controlplane/kubeadm/reconcilers/kubeadmcontrolplane/status.go(inupdateV1Beta1StatusandupdateStatus), do check the returned error:Since the error was always
nil, those checks could never fire.The practical effect is that a transient failure to reach the workload cluster made KCP conclude the control plane was not initialized, so it left
status.initialization.controlPlaneInitializedand theAvailablecondition unset and waited for the next resync instead of surfacing the failure and retrying. The error was also invisible to operators, since it was neither returned nor logged.This addresses the first of the two pre-existing TODOs on that function. The second one, about introducing a third "unknown" state, is intentionally left alone as it would be an API change for
WorkloadCluster.Changes:
HasKubeadmConfignow maps onlyNotFoundtofalse; any other error is returned to the caller, which makes the existing error handling in both callers effective.NotFounderror, injected withinterceptor.NewClient. TheexpectErrfield already present in the test table was previously unused, so no case exercised the error path.Which issue(s) this PR fixes:
Additional context:
Verified that the new test case fails against the current implementation on
mainand passes with the change, so it genuinely covers the fixed behaviour.make lintand the full./controlplane/kubeadm/...suite pass./area control-plane