Repository navigation
Conversation
With unsafeCustomBuildID set, the in-place update stored a hash of the template after controller env vars and volumes were applied, but creation and the drift check hash the user template before them, so the hashes never matched. Hash the user template first, and deep-copy it so controller changes don't mutate.
tomba7
approved these changes
Oct 20, 2026
| wdDepSpec := spec.DeploymentSpec() | ||
| // Hash the user template, excluding controller-managed fields. | ||
| podTemplateSpecHash := k8s.ComputePodTemplateSpecHash(wdDepSpec.Template) | ||
| wdDepSpec.Template = *wdDepSpec.Template.DeepCopy() |
Collaborator
There was a problem hiding this comment.
small nit: could we add a comment explaining this deep copy? It wasn't clear at first glance why it's needed to protect spec.template without looking at the unit test.
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.
What was changed
updateDeploymentWithPodTemplateSpecnow hashes the user-provided template before controller modifications get applied. This aligns it with the drift check and creation steps.Also deep-copies the template before modifications.
DeploymentSpec()only copied the template on the legacy path whenspec.deploymentis nil, so applying env vars or volumes could mutate theWorkerDeploymentSpec. This was latent previously, but the change to the hash order made it salient.Why?
When
unsafeCustomBuildIDis set, changing a pod template field is applied in place to the existing deployment, so after a first update the controller could see drift every 10s (i.e. per reconcile) and re-send the same update. Thankfully these were no-ops on the server side, but it still cost an API call and a log line, and could be a potential footgun.This was because the
temporal.io/pod-template-specwas computed from differnt inputs at creation vs update time.Checklist
Closes [Bug] With a pinned build ID, the controller keeps updating the Deployment after a template change #656
How was this tested:
TestCheckAndUpdateDeploymentPodTemplateSpecno re-runs the check on its result and asserts that there was no second update. This fails on main but is fixed in this branch. The test also now asserts that the input spec is not mutated.None required