Skip to content

fix: use HookSucceeded with orphan propagation for oneShot ExternalSecret#15

Merged
minmzzhang merged 3 commits into
validatedpatterns:mainfrom
minmzzhang:one-shot-keycloak-users-v2
May 29, 2026
Merged

fix: use HookSucceeded with orphan propagation for oneShot ExternalSecret#15
minmzzhang merged 3 commits into
validatedpatterns:mainfrom
minmzzhang:one-shot-keycloak-users-v2

Conversation

@minmzzhang
Copy link
Copy Markdown
Contributor

Switch the oneShot hook-delete-policy from BeforeHookCreation to HookSucceeded so the keycloak-users ExternalSecret is removed as early as possible after syncing. Add PrunePropagationPolicy=orphan to prevent ArgoCD from cascade-deleting the K8s Secret when the ExternalSecret is pruned. Remove the one-shot label on the ExternalSecret itself since HookSucceeded handles its deletion. Rename the cleanup label from ztvp.io/cleanup to validatedpatterns.io/cleanup.

…cret

Switch the oneShot hook-delete-policy from BeforeHookCreation to
HookSucceeded so the keycloak-users ExternalSecret is removed as
early as possible after syncing.  Add PrunePropagationPolicy=orphan
to prevent ArgoCD from cascade-deleting the K8s Secret when the
ExternalSecret is pruned.  Remove the one-shot label on the
ExternalSecret itself since HookSucceeded handles its deletion.
Rename the cleanup label from ztvp.io/cleanup to
validatedpatterns.io/cleanup.

Signed-off-by: Min Zhang <minzhang@redhat.com>
Copy link
Copy Markdown
Contributor

@mlorenzofr mlorenzofr left a comment

Choose a reason for hiding this comment

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

I was testing it but I found some problems with the cleanup job

Comment thread templates/keycloak-users-external-secret.yaml
Copy link
Copy Markdown
Contributor

@mlorenzofr mlorenzofr left a comment

Choose a reason for hiding this comment

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

The keycloak app and the import and cleanup jobs are working correctly. The keycloak-users secret has been successfully deleted. The NPs have been applied. Everything OK

LGTM

…neShot

Replace deletionPolicy: Retain with creationPolicy: Orphan when oneShot
is enabled. Orphan prevents ESO from setting an ownerReference on the
Secret, so Kubernetes GC will not cascade-delete it when ArgoCD removes
the ExternalSecret hook. Add creationPolicy as a configurable value
(default: Owner) for the non-oneShot case.

Signed-off-by: Min Zhang <minzhang@redhat.com>
Copy link
Copy Markdown
Contributor

@sabre1041 sabre1041 left a comment

Choose a reason for hiding this comment

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

Thanks @minmzzhang for working through the deletion issues. Can you regenerate the README so that it includes the creationPolicy value?

helm-docs generates compact markdown tables that fail the super-linter
prettier check. Add a containerized prettier step (jauderho/prettier)
to the helm-docs target so README.md is always formatted correctly.

Signed-off-by: Min Zhang <minzhang@redhat.com>
@minmzzhang
Copy link
Copy Markdown
Contributor Author

Thanks @minmzzhang for working through the deletion issues. Can you regenerate the README so that it includes the creationPolicy value?

The README.md is regenerated with the latest contents. I also updated the Makefile to include a prettier formatting as the current one always fails the super-linter.

Copy link
Copy Markdown
Contributor

@sabre1041 sabre1041 left a comment

Choose a reason for hiding this comment

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

LGTM!

@minmzzhang minmzzhang merged commit b82a485 into validatedpatterns:main May 29, 2026
3 checks passed
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.

3 participants