Run namespace creation as a post-install/post-upgrade Helm hook - #956
Merged
Merged
Conversation
The namespace job (temporalio#892) was deliberately kept out of Helm's hook system because the schema job uses pre-install/pre-upgrade hooks, which run before any other resources exist — making namespace creation a pre-hook too would deadlock, since it needs the frontend service and that's only created after hooks succeed. post-install/post-upgrade hooks run the opposite side of that boundary: after normal resources (including the frontend Deployment/Service) are applied, so there's no deadlock. Using a real hook here (mirroring the useHelmHooks toggle already used for schema.useHelmHooks) means: - The job gets a stable name and is cleaned up via before-hook-creation,hook-succeeded instead of accumulating a new Job object (named by chart version + release revision) on every install/upgrade. - Helm waits for namespace creation to finish before considering the release complete, rather than firing-and-forgetting a plain Job. useHelmHooks defaults to true but can be set to false to keep the prior behavior, matching schema.useHelmHooks for Flux/Rancher/Terraform users.
|
|
robholland
approved these changes
Jul 27, 2026
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
#892 intentionally kept namespace creation out of Helm's hook system because the schema job (
server-job.yaml) usespre-install,pre-upgradehooks. Since all pre-install/pre-upgrade hooks run before any other resource is applied, making the namespace job a pre-hook too would deadlock: it needs the frontend service, which doesn't exist until after hooks succeed. So the namespace job was left as a plainJob, named with the chart version + release revision baked in to avoid the "Job spec is immutable" problem across upgrades.That workaround has a couple of downsides:
Jobobject is left behind on every install/upgrade (cleaned up only viattlSecondsAfterFinished, not immediately).post-install,post-upgradehooks avoid the deadlock from #892 entirely, since they run on the other side of that boundary — after normal resources (including the frontend Deployment/Service) are already applied. This PR switches the namespace job to use them by default, mirroring theuseHelmHookstoggle that already exists for the schema job:server.config.namespaces.useHelmHooks(defaulttrue) makes the job usehelm.sh/hook: post-install,post-upgradewithbefore-hook-creation,hook-succeededdeletion, and a stable name (<release>-<chart>-namespace) instead of the version/revision-suffixed one.falsepreserves the exact previous behavior (plain Job, versioned name), for Flux/Rancher/Terraform users the same wayschema.useHelmHooks: falsealready works.Test plan
helm unittest charts/temporal— all 147 existing tests pass, plus new/updated tests for the namespace job (13 total in that suite) covering: default hook annotations, stable job name,useHelmHooks: falsefallback (annotations absent, versioned name preserved).helm templatesanity-checked againstcharts/temporal/ci/postgres-values.yamlfor bothuseHelmHooks: true(default) anduseHelmHooks: false, confirming output matches the intended behavior in each mode.ct installagainst a kind cluster (existing coverage already exercisesserver.config.namespaces.create: trueviaci/postgres-values.yaml).