fix(imagehub): stop rotating image registry robot secrets on every reconcile - #88
Draft
pranludi wants to merge 1 commit into
Draft
fix(imagehub): stop rotating image registry robot secrets on every reconcile#88pranludi wants to merge 1 commit into
pranludi wants to merge 1 commit into
Conversation
…concile ImageRegistrySecretReconciler called AipubDockerConfigJsonResolver's refreshSecret() unconditionally every time it reconciled a project's .dockerconfigjson Secret — including on every project-controller restart (informer resync re-lists all Projects) and any unrelated change to spec.binding.imageHubs (e.g. adding a second, unrelated ImageHub). Harbor robot permissions are updated independently of the robot's secret, so this rotation was never actually necessary once a working Secret already existed; it only invalidated whatever was previously working. Confirmed live on cluster12: adding a second ImageHub binding to an already-connected project immediately broke docker login with the previously-valid robot password, even with zero restarts/crashes. Fix: track which robot's secret is currently reflected in the K8s Secret via a new project.aipub.ten1010.io/image-registry-robot-id annotation. Only call refreshSecret() when the project's current robot id differs from what's recorded (i.e. the robot was actually recreated) or when the Secret doesn't exist yet. Otherwise reuse the existing Secret data as-is. Note: pre-existing Secrets created before this change won't have the annotation yet, so they'll get one extra (harmless) rotation the first time they're reconciled after this fix ships, after which they settle into the new behavior permanently. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
4 tasks
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.
Summary
ImageRegistrySecretReconcilercalledrefreshSecret()(viaAipubDockerConfigJsonResolver) unconditionally every time it reconciled a project's.dockerconfigjsonSecret — not just at first creation. This fires on:spec.binding.imageHubs, including adding a second, unrelated ImageHub to an already-connected projectHarbor robot permissions are updated independently of the robot's secret (
PUT /robots/{id}vsPUT /robots/{id}/refreshsecret), so this rotation was never actually necessary once a working Secret already existed — it just invalidated whatever password was currently in use, with no warning.Confirmed live on cluster12: created a project, connected one ImageHub,
docker loginwith the resulting secret succeeded. Added a second, unrelated ImageHub binding to the same project (no restart, no crash) — the previously-working password immediately stopped authenticating, while the new one (silently rotated in) worked fine.Fix
Track which robot's secret is currently reflected in the K8s Secret via a new
project.aipub.ten1010.io/image-registry-robot-idannotation. Only callrefreshSecret()when:Otherwise, reuse the existing Secret's
.dockerconfigjsondata as-is — permission-only changes no longer touch the password at all.Note on rollout
Secrets created before this change won't have the annotation yet, so each will get one extra (harmless) rotation the first time it's reconciled after this ships. After that they settle into the new behavior permanently and stop rotating on unrelated changes.
Follow-up (separate, cross-repo — not in this PR)
Even after this fix, first-time robot creation still costs two Harbor round-trips (create, then refresh-secret) because aipub-backend discards the plaintext secret Harbor already returns at creation time, at three layers (
backend-api's Harbor client call, the create gRPC response, and the gateway REST controller returningVoid). Propagating that through would let project-controller seed the Secret directly from the create response. Tracked separately since it requires aipub-backend changes too — marking this PR as draft until that's scoped/decided, and this one is deliberately self-contained without a testing plan.Test plan
./gradlew compileJava/./gradlew build -x testpass🤖 Generated with Claude Code