fix: never delete namespace on deployment down
down() deleted the entire namespace when it wasn't explicitly set in the spec. This causes a race condition on restart: up() tries to create resources in a namespace that's still terminating, getting 403 Forbidden. Always use _delete_resources_by_label() instead. The namespace is cheap to keep and required for immediate up() after down(). This also matches the shared-namespace behavior, making down() consistent regardless of namespace configuration. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>afd-dumpster-local-testing
parent
e298e7444f
commit
ae2cea3410
|
|
@ -581,14 +581,11 @@ class K8sDeployer(Deployer):
|
||||||
if opts.o.debug:
|
if opts.o.debug:
|
||||||
print(f"Error listing PVs: {e}")
|
print(f"Error listing PVs: {e}")
|
||||||
|
|
||||||
# When namespace is explicitly set in the spec, it may be shared with
|
# Always delete resources by label, never delete the namespace itself.
|
||||||
# other stacks — delete only this stack's resources by label.
|
# Namespace deletion causes a race condition on restart: up() tries to
|
||||||
# Otherwise the namespace is owned by this deployment, delete it entirely.
|
# create resources in a namespace that's still terminating (403 Forbidden).
|
||||||
shared_namespace = self.deployment_context.spec.get_namespace() is not None
|
# The namespace is cheap to keep and required for immediate up() after down().
|
||||||
if shared_namespace:
|
self._delete_resources_by_label(app_label, volumes)
|
||||||
self._delete_resources_by_label(app_label, volumes)
|
|
||||||
else:
|
|
||||||
self._delete_namespace()
|
|
||||||
|
|
||||||
if self.is_kind() and not self.skip_cluster_management:
|
if self.is_kind() and not self.skip_cluster_management:
|
||||||
# Destroy the kind cluster
|
# Destroy the kind cluster
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue