fix: clean up Temporal server-side versioning data on TWD deletion#240
Open
anujagrawal380 wants to merge 5 commits intotemporalio:mainfrom
Open
fix: clean up Temporal server-side versioning data on TWD deletion#240anujagrawal380 wants to merge 5 commits intotemporalio:mainfrom
anujagrawal380 wants to merge 5 commits intotemporalio:mainfrom
Conversation
…blocking unversioned workers Signed-off-by: Anuj Agrawal <anujagrawal380@gmail.com>
Author
|
PTAL @carlydf |
Signed-off-by: Anuj Agrawal <anujagrawal380@gmail.com>
jaypipes
reviewed
Mar 25, 2026
jaypipes
left a comment
There was a problem hiding this comment.
@anujagrawal380 awesome contribution, thank you so much for this PR! I couple really minor comments below, but overall excellent work.
Signed-off-by: Anuj Agrawal <anujagrawal380@gmail.com>
Signed-off-by: Anuj Agrawal <anujagrawal380@gmail.com>
Author
Thanks, resolved both the comments! |
jaypipes
approved these changes
Mar 25, 2026
jaypipes
left a comment
There was a problem hiding this comment.
rock on :) nice work on this @anujagrawal380!
carlydf
requested changes
Mar 25, 2026
Collaborator
carlydf
left a comment
There was a problem hiding this comment.
we need integration tests for this before merging to main / including it in a release
Signed-off-by: Anuj Agrawal <anujagrawal380@gmail.com>
Author
@carlydf Added the integration tests. PTAL |
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.
TemporalWorkerDeploymentto run Temporal server-side cleanup before K8s deletionTemporalConnectionto prevent it from being deleted while any TWD still references itProblem
When a
TemporalWorkerDeploymentCRD is deleted (e.g., switching back to plain Deployments), the Temporal server retains the build ID routing configuration. The matching service continues routing new tasks to the deleted build ID's physical queue, while unversioned workers poll a different physical queue. Tasks sit inScheduledstate indefinitely with no errors.A secondary race condition exists: Helm deletes both the
TemporalConnectionandTWDin the same upgrade. Without the connection, the controller cannot talk to Temporal to clean up. This is solved by adding a finalizer to theTemporalConnectionthat blocks its deletion until all referencing TWDs are gone.Changes
internal/controller/worker_controller.go:TWD finalizer (
temporal.io/worker-deployment-cleanup):handleDeletion()which:BuildID: "") -- the critical step that unblocks task dispatchSkipDrainage: trueTemporalConnection finalizer (
temporal.io/connection-in-use):TemporalConnectionduring normal TWD reconciliation viaensureConnectionFinalizer()removeConnectionFinalizerIfUnused()during TWD deletion, after checking no other TWDs in the same namespace reference the connectionRBAC updates:
update;patchverbs fortemporalconnections(wasget;list;watch)updateverb fortemporalconnections/finalizersDeletion flow
Issue #55
Issue #166