Source
Upstream issue: alexandrevilain#943 — "Cannot delete namespaces"
When trying to delete a TemporalNamespace I often encounter issues where the operator gets stuck and fails to reconcile Temporal namespaces … ERROR Reconciler error … unable to patch object: TemporalNamespace.temporal.io "debugging" is invalid: metadata.finalizers: Forbidden: no new finalizers can be added if the object is being deleted, found new finalizers []string{"foregroundDeletion"} … I usually have to manually remove the finalizer from the TemporalNamespace object and also restart the operator itself as it gets stuck.
Why it fits this operator
Deleting a TemporalNamespace is a first-class operator lifecycle operation. A namespace that cannot be deleted (operator stuck in a loop, forced to hand-remove Kubernetes finalizers and restart the controller) leaves garbage workflows behind and blocks cluster teardown. This is core reconciler/finalizer logic — the operator's responsibility.
Proposed implementation
- Finalizer guard — in the
TemporalNamespace finalizer/deletion path, never re-add a finalizer once Kubernetes has marked the object as being deleted (foregroundDeletion present → abort cleanly instead of re-patching).
- Idempotent deletion — when the namespace is already absent on the Temporal server (
try to delete but not found), treat "not found" as success and finish removing CRD-side resources instead of erroring/looping.
- Reconcile self-heal — on a failed delete reconcile, surface a clear reconcile-blocked state instead of repeatedly re-patching the same invalid object (the cause of the stuck loop).
Affected areas
TemporalNamespace controller / reconciler deletion path
- Finalizer logic (
controllers/finalizer)
- Error handling for the namespace-delete RPC (
not found)
Risks / migration concerns
- Deletion is destructive — keep the delete-vs-patch distinction; never silently skip when the namespace exists on the server.
- Needs e2e coverage (create → delete → re-create) so the fix doesn't reintroduce stuck/finalizer states.
- Tracks the still-open upstream defect.
Source
Upstream issue: alexandrevilain#943 — "Cannot delete namespaces"
Why it fits this operator
Deleting a
TemporalNamespaceis a first-class operator lifecycle operation. A namespace that cannot be deleted (operator stuck in a loop, forced to hand-remove Kubernetes finalizers and restart the controller) leaves garbage workflows behind and blocks cluster teardown. This is core reconciler/finalizer logic — the operator's responsibility.Proposed implementation
TemporalNamespacefinalizer/deletion path, never re-add a finalizer once Kubernetes has marked the object as being deleted (foregroundDeletionpresent → abort cleanly instead of re-patching).try to delete but not found), treat "not found" as success and finish removing CRD-side resources instead of erroring/looping.Affected areas
TemporalNamespacecontroller / reconciler deletion pathcontrollers/finalizer)not found)Risks / migration concerns