Skip to content

Run namespace creation as a post-install/post-upgrade Helm hook - #956

Merged
robholland merged 1 commit into
temporalio:mainfrom
Summonair:namespace-job-helm-hooks
Jul 27, 2026
Merged

Run namespace creation as a post-install/post-upgrade Helm hook#956
robholland merged 1 commit into
temporalio:mainfrom
Summonair:namespace-job-helm-hooks

Conversation

@Summonair

Copy link
Copy Markdown
Contributor

Summary

#892 intentionally kept namespace creation out of Helm's hook system because the schema job (server-job.yaml) uses pre-install,pre-upgrade hooks. 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 plain Job, 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:

  • A new completed Job object is left behind on every install/upgrade (cleaned up only via ttlSecondsAfterFinished, not immediately).
  • It's a plain resource, so Helm doesn't wait on it by default — namespace creation is fire-and-forget rather than something the release can be said to have completed.

post-install,post-upgrade hooks 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 the useHelmHooks toggle that already exists for the schema job:

  • server.config.namespaces.useHelmHooks (default true) makes the job use helm.sh/hook: post-install,post-upgrade with before-hook-creation,hook-succeeded deletion, and a stable name (<release>-<chart>-namespace) instead of the version/revision-suffixed one.
  • Setting it to false preserves the exact previous behavior (plain Job, versioned name), for Flux/Rancher/Terraform users the same way schema.useHelmHooks: false already 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: false fallback (annotations absent, versioned name preserved).
  • helm template sanity-checked against charts/temporal/ci/postgres-values.yaml for both useHelmHooks: true (default) and useHelmHooks: false, confirming output matches the intended behavior in each mode.
  • CI's ct install against a kind cluster (existing coverage already exercises server.config.namespaces.create: true via ci/postgres-values.yaml).

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.
@Summonair
Summonair requested a review from a team as a code owner July 23, 2026 16:39
@CLAassistant

CLAassistant commented Jul 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@robholland robholland self-assigned this Jul 27, 2026
@robholland
robholland merged commit ec055ab into temporalio:main Jul 27, 2026
4 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