Skip to content

fix: use constant name for schema job to enable proper hook cleanup#916

Open
celestegambardella wants to merge 1 commit into
temporalio:mainfrom
celestegambardella:fix-schema-job-constant-name
Open

fix: use constant name for schema job to enable proper hook cleanup#916
celestegambardella wants to merge 1 commit into
temporalio:mainfrom
celestegambardella:fix-schema-job-constant-name

Conversation

@celestegambardella
Copy link
Copy Markdown

The schema job name previously included Chart.Version and Release.Revision, which caused the job name to change on every upgrade. This prevented 'before-hook-creation' delete policy from cleaning up old jobs since Helm treats differently-named resources as unrelated. Using a constant job name ensures proper cleanup during upgrades and prevents manual job deletion during version upgrades. Fixes hook cleanup issue with pre-install,pre-upgrade schema jobs.

What was changed

Changed the schema job name from a dynamic name including Chart.Version and Release.Revision to a constant name based only on the release name.

Before

{{ $jobName := include "temporal.componentname" (list $ (printf "schema-%s-%d" $.Chart.Version $.Release.Revision | replace "." "-" | replace "+" "-")) }}

After

{{ $jobName := printf "%s-schema" (include "temporal.fullname" $) }}

Why?

The dynamic job name caused the name to change on every upgrade (e.g., temporal-schema-0-62-0-1 → temporal-schema-0-63-0-2). This prevented before-hook-creation delete policy from working because Helm treats
differently-named resources as unrelated.

This resulted in:
• Old completed jobs accumulating in the cluster
• Manual job deletion required during upgrades
• Failed upgrades if jobs with conflicting names exist

Using a constant name ensures before-hook-creation properly cleans up old jobs during upgrades.

Alternative (If Constant Name Is Not Acceptable)

If maintaining dynamic job names is preferred, I can add an option to use post-install,post-upgrade hooks with hook-succeeded delete policy instead:

schema:
  useHelmHooks: true
  hookTiming: "post-install,post-upgrade"  # NEW option, default "pre-install,pre-upgrade"

This would enable automatic cleanup without changing the job naming scheme. Let me know which approach is preferred.

Checklist

  1. How was this tested:
  • helm template renders correctly with constant job name
  • Local Kind cluster: install → verify job runs → upgrade → verify old job deleted, new job created
  1. Any docs updates needed?

• No README updates needed (internal template change)
• May want to mention in upgrade notes that schema job name format changed

@celestegambardella celestegambardella requested a review from a team as a code owner May 16, 2026 02:40
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 16, 2026

CLA assistant check
All committers have signed the CLA.

@celestegambardella celestegambardella force-pushed the fix-schema-job-constant-name branch from 700fb15 to 3023cc2 Compare May 18, 2026 17:24
The schema job name previously included Chart.Version and Release.Revision,
which caused the job name to change on every upgrade. This prevented
'before-hook-creation' delete policy from cleaning up old jobs since
Helm treats differently-named resources as unrelated.
Using a constant job name ensures proper cleanup during upgrades
and prevents manual job deletion during version upgrades.
Fixes hook cleanup issue with pre-install,pre-upgrade schema jobs.
@celestegambardella celestegambardella force-pushed the fix-schema-job-constant-name branch from 3023cc2 to 3460624 Compare May 18, 2026 17:27
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.

2 participants