fix(): updateDashboardCreds uses deprecated ServiceAccount.Secrets field removed in K8s 1.24+#490
Open
mdryaan wants to merge 1 commit into
Open
Conversation
…n updateDashboardCreds Signed-off-by: Md Raiyan <alikhurshid842001@gmail.com>
Author
|
Hey @gourishkb @Rahul-D78, Could you please have a look at this PR whenever you have time? Thanks! |
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.
Description
updateDashboardCredsinpkg/hub/controllers/cluster/reconciler.gowas fetching the dashboard token secret viasa.Secrets[0].Name. Before Kubernetes 1.24, the API server auto-created akubernetes.io/service-account-tokenSecret for every ServiceAccount and populatedServiceAccount.Secretswith its name. Since 1.24 that auto-creation was removedsa.Secretsis always empty on modern clusters unless a legacy token secret is manually created.On any K8s 1.24+ cluster this causes
updateDashboardCredsto return"ServiceAccount has no secret"on every single reconcile. Because the error short-circuitsReconcile()beforeupdateClusterHealthStatusandupdateClusterMetricsare reached, cluster health status never updates as long as the dashboard SA has no manually-created legacy secret.Fix: remove the ServiceAccount fetch and replace it with
r.MeshClient.Listover secrets in the control plane namespace, filtering byType == kubernetes.io/service-account-tokenandAnnotations["kubernetes.io/service-account.name"] == KubeSliceDashboardSA. This is the correct approach for K8s 1.24+ where token secrets must be created manually and discovered by annotation.Fixes #489
How Has This Been Tested?
Test_updateDashboardCreds/no_token_secret_found— empty list returns correct errorTest_updateDashboardCreds/token_secret_found_via_annotation— annotated token secret found, full success path confirmedmake fmt— no formatting changesmake vet— no issuesmake build— builds cleanlymake test— all suites pass; 6 pre-existing spoke timeout failures confirmed identical on master (require live cluster)Checklist:
go fmtDoes this PR introduce a breaking change?