Skip to content

fix(service): check for the token Secret itself, not the ServiceAccount - #421

Open
sumanthd032 wants to merge 1 commit into
kubeslice:masterfrom
sumanthd032:fix/sa-token-secret-existence-check
Open

fix(service): check for the token Secret itself, not the ServiceAccount#421
sumanthd032 wants to merge 1 commit into
kubeslice:masterfrom
sumanthd032:fix/sa-token-secret-existence-check

Conversation

@sumanthd032

@sumanthd032 sumanthd032 commented Aug 5, 2026

Copy link
Copy Markdown

Description

Fixes cluster reconciliation to check for the token Secret's own existence, not the ServiceAccount's. Deleting the token Secret by hand previously left the cluster permanently broken, since the creation branch is skipped whenever the ServiceAccount is present. Unrelated to the HA work; a standalone fix on the cluster-registration path.

How Has This Been Tested?

Verified against a live cluster: deleted the token Secret while leaving the ServiceAccount in place. Before: reconcile errors every cycle, no Secret recreated. After: the Secret is recreated and the errors stop.

No unit test: the service test package doesn't currently compile on master (undefined util.Client in three test files, filed separately).

Checklist:

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR requires documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have tested it for all user roles.
  • I have added all the required unit test cases.

Does this PR introduce a breaking change for other components like worker-operator?

No. Behavior-neutral except when the Secret was already missing, which was already a hard failure.


The worker ServiceAccount's token Secret is only ever created inside the
branch that creates the ServiceAccount. That assumes the two are always
absent together, which holds when this routine created both and fails as
soon as one of them goes missing on its own.

Delete a cluster's token Secret by hand and there is no way back. The
ServiceAccount is still present, so the branch is skipped, no token is ever
minted, and every subsequent reconcile of that cluster fails on the missing
Secret. The requeue guard in ClusterService.ReconcileCluster does not catch
it either, for a reason that is easy to miss: the ServiceAccount is built
with its Secrets reference already populated, so it claims a Secret that
does not exist and the check passes.

Checking for the Secret's own existence is behaviour-neutral in the ordinary
case, where the Secret is present whenever the account is, and restores the
cluster in the case above.

Verified against a live cluster by deleting the token Secret while leaving
the ServiceAccount in place: before, 28 "could not find secret" reconcile
errors in 45 seconds and no Secret; after, the Secret is recreated and
populated and the errors stop. Re-running with both already present produces
no creation events and leaves the Secret's UID unchanged.

No unit test accompanies this because the service test package does not
compile on master, independently of this change: undefined util.Client in
three test files, plus an unknown ClusterName field in
worker_slice_gateway_service_test.go. Filed separately.

Signed-off-by: Sumanth D <sumanthd032@gmail.com>
Copilot AI lite review requested due to automatic review settings August 5, 2026 06:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants