Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions internal/planner/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,11 @@ func updateDeploymentWithPodTemplateSpec(
connection temporaliov1alpha1.ConnectionSpec,
) {
wdDepSpec := spec.DeploymentSpec()
// Hash the user template, excluding controller-managed fields.
podTemplateSpecHash := k8s.ComputePodTemplateSpecHash(wdDepSpec.Template)
// DeploymentSpec() shares the template with spec on the legacy spec.template path;
// copy so the modifications below don't mutate spec.
wdDepSpec.Template = *wdDepSpec.Template.DeepCopy()
Comment thread
jaypipes marked this conversation as resolved.

// Extract the build ID from the deployment's labels (with nil safety)
var buildID string
Expand Down Expand Up @@ -659,8 +664,7 @@ func updateDeploymentWithPodTemplateSpec(
podAnnotations[k] = v
}
podAnnotations[k8s.ConnectionSpecHashAnnotation] = k8s.ComputeConnectionSpecHash(connection)
// Store the new pod template spec hash
podAnnotations[k8s.PodTemplateSpecHashAnnotation] = k8s.ComputePodTemplateSpecHash(wdDepSpec.Template)
podAnnotations[k8s.PodTemplateSpecHashAnnotation] = podTemplateSpecHash

// Preserve existing pod labels and add/update required labels
podLabels := make(map[string]string)
Expand Down
5 changes: 5 additions & 0 deletions internal/planner/planner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3388,7 +3388,9 @@ func TestCheckAndUpdateDeploymentPodTemplateSpec(t *testing.T) {
k8sState.Deployments[buildID] = tt.existingDeployment
}

originalSpec := tt.newSpec.DeepCopy()
result := checkAndUpdateDeploymentPodTemplateSpec(buildID, k8sState, tt.newSpec, tt.connection)
assert.Equal(t, originalSpec, tt.newSpec, "Controller modifications must not mutate the worker spec")

if !tt.expectUpdate {
assert.Nil(t, result, "Expected no update, but got deployment")
Expand All @@ -3415,6 +3417,9 @@ func TestCheckAndUpdateDeploymentPodTemplateSpec(t *testing.T) {
}
}
assert.True(t, found, "Should find TEMPORAL_WORKER_BUILD_ID environment variable")

assert.Nil(t, checkAndUpdateDeploymentPodTemplateSpec(buildID, k8sState, tt.newSpec, tt.connection),
"An unchanged pod template should not trigger another update")
})
}
}
Expand Down
Loading