Skip to content

fix(controller): retry unsynced SealedSecrets when a new key is registered - #2098

Open
lbarrosby wants to merge 1 commit into
bitnami:mainfrom
lbarrosby:fix/requeue-on-new-key
Open

lbarrosby wants to merge 1 commit into
bitnami:mainfrom
lbarrosby:fix/requeue-on-new-key

Conversation

@lbarrosby

Copy link
Copy Markdown

Description of the change

With --watch-for-secrets (added in #2034) the controller registers sealing keys that show up after startup, for example a key restored from backup after it was deleted by mistake. SealedSecrets that already failed with no key could decrypt secret are never retried, though: they burn through --max-unseal-retries within milliseconds, get forgotten by the queue, and nothing requeues them when the key comes back. They stay Synced=False (and the Secret stays missing) until the controller restarts.

This change requeues every SealedSecret that is not known to be synced (no status, or Synced not True) whenever a key is added to or updated in the registry. Synced SealedSecrets are left alone, so a normal key renewal does not re-process the whole cluster.

Benefits

Restoring a lost key heals the affected SealedSecrets without a controller restart, and the Synced condition (and alerts/health checks built on it, e.g. Argo CD) clears on its own.

Possible drawbacks

Each key add/update walks the SealedSecret cache of that controller once. Only unsynced items are queued, and the queue deduplicates.

Applicable issues

Additional information

TestNewKeyRequeuesUnsyncedSealedSecrets runs the real controller against fake clients: the SealedSecret is sealed with a key that is not in the registry, the controller gives up (maxRetries=1), then the key Secret is created. It fails on main (expected Synced=True after the key was added, got "False") and passes with the change. go test ./pkg/... ./cmd/... and golangci-lint run ./pkg/controller/ are clean.

…tered

With --watch-for-secrets the controller picks up sealing keys created or
restored after startup, but SealedSecrets that already failed with
"no key could decrypt secret" are never retried: they exhaust
--max-unseal-retries within milliseconds and nothing requeues them, so
they stay Synced=False until the controller is restarted.

Requeue every SealedSecret that is not known to be synced whenever a key
is added or updated in the registry.

Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>

This branch has not been deployed

No deployments
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.

1 participant