fix secret sync wait to require requested keys#170
Merged
Conversation
vigneshrajsb
approved these changes
Apr 16, 2026
Contributor
vigneshrajsb
left a comment
There was a problem hiding this comment.
Looks good.
Secret sync was apparently doing security through obscurity by letting new keys play hide-and-seek with the pod. This fix makes the secret wait until all the requested env keys actually show up, which is a much better magician than the old implementation.
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.
When a PR already has a Lifecycle-managed secret and a later commit adds a new secret reference in lifecycle.yaml, secret sync can complete too early.
The current sync check only verifies that the target Kubernetes Secret exists and has some data. For existing PRs, the Secret may already exist from a previous deploy with older keys, so the sync step treats it as ready before External Secrets Operator has reconciled the newly requested key. The build or runtime pod can then start without the new env var populated.
New PRs, or PRs that previously had no secrets, usually work because the target Secret does not exist yet, so the sync loop waits through 404 until ESO creates it.
Expected behavior
Secret sync should only complete after the target Kubernetes Secret contains every key requested by the current lifecycle.yaml change.
Fix
Track the expected env keys per generated Secret and update waitForSecretSync to poll until each requested key is present. Timeout errors should include the missing keys for debugging.
Validation
Add regression coverage for:
existing Secret with old keys missing a newly requested key
Secret appearing after 404
multi-key sync waiting for the last key
empty-but-present secret values not being treated as missing