Skip to content

Commit a193e16

Browse files
committed
refactor: option k8s delete propagation policy
Signed-off-by: thxCode <[email protected]>
1 parent c1c6ac1 commit a193e16

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

gpustack_runtime/deployer/kuberentes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,7 @@ def _delete(
16111611
core_api.delete_collection_namespaced_pod(
16121612
namespace=namespace,
16131613
label_selector=f"{_LABEL_WORKLOAD}={name}",
1614-
propagation_policy="Foreground",
1614+
propagation_policy=envs.GPUSTACK_RUNTIME_KUBERNETES_DELETE_PROPAGATION_POLICY,
16151615
)
16161616
except kubernetes.client.exceptions.ApiException as e:
16171617
msg = f"Failed to delete pod of workload {name}{_detail_api_call_error(e)}"
@@ -1622,7 +1622,7 @@ def _delete(
16221622
core_api.delete_collection_namespaced_service(
16231623
namespace=namespace,
16241624
label_selector=f"{_LABEL_WORKLOAD}={name}",
1625-
propagation_policy="Foreground",
1625+
propagation_policy=envs.GPUSTACK_RUNTIME_KUBERNETES_DELETE_PROPAGATION_POLICY,
16261626
)
16271627
except kubernetes.client.exceptions.ApiException as e:
16281628
msg = f"Failed to delete service of workload {name}{_detail_api_call_error(e)}"
@@ -1633,7 +1633,7 @@ def _delete(
16331633
core_api.delete_collection_namespaced_config_map(
16341634
namespace=namespace,
16351635
label_selector=f"{_LABEL_WORKLOAD}={name}",
1636-
propagation_policy="Foreground",
1636+
propagation_policy=envs.GPUSTACK_RUNTIME_KUBERNETES_DELETE_PROPAGATION_POLICY,
16371637
)
16381638
except kubernetes.client.exceptions.ApiException as e:
16391639
msg = f"Failed to delete configmap of workload {name}{_detail_api_call_error(e)}"

gpustack_runtime/envs.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@
243243
"""
244244
Whether to use quorum read for Kubernetes services.
245245
"""
246+
GPUSTACK_RUNTIME_KUBERNETES_DELETE_PROPAGATION_POLICY: str | None = None
247+
"""
248+
Deletion propagation policy for Kubernetes resources (e.g., Foreground, Background, Orphan).
249+
"""
246250

247251
# --8<-- [start:env-vars-definition]
248252

@@ -459,6 +463,14 @@
459463
"GPUSTACK_RUNTIME_KUBERNETES_QUORUM_READ": lambda: to_bool(
460464
getenv("GPUSTACK_RUNTIME_KUBERNETES_QUORUM_READ", "0"),
461465
),
466+
"GPUSTACK_RUNTIME_KUBERNETES_DELETE_PROPAGATION_POLICY": lambda: choice(
467+
getenv(
468+
"GPUSTACK_RUNTIME_KUBERNETES_DELETE_PROPAGATION_POLICY",
469+
"Foreground",
470+
),
471+
options=["Foreground", "Background", "Orphan"],
472+
default="Background",
473+
),
462474
}
463475

464476

0 commit comments

Comments
 (0)