Skip to content

Support orphan cleanup in the Kubernetes backend - #4455

Merged
r4victor merged 3 commits into
masterfrom
issue_3453_kubernetes_orphan_cleanup
Nov 3, 2026
Merged

r4victor merged 3 commits into
masterfrom
issue_3453_kubernetes_orphan_cleanup

Conversation

@r4victor

@r4victor r4victor commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Adds orphan cleanup support to the kubernetes backend, part of #3453.

  • Job pods, their services, and their registry auth secrets are labeled with k8s.dstack.ai/provider-ref.
  • list_resource_groups() lists labeled pods, services, and secrets in each cluster's namespace and groups them by job pod (app.kubernetes.io/instance), so each provisioning attempt is a separate group. Finished pods are listed, while pods being deleted are skipped and their services and secrets are listed without them.
  • delete_resource_group() deletes the pod and the service and secret named after it, like terminate_instance(), in one step.
  • The documented Role grants list on services and secrets. If listing them is forbidden, the cleanup logs a warning and skips them instead of failing the cluster: pods still delete their services and secrets by name, and only those left without pods are missed. The docs note that list on secrets exposes all secrets in the namespace, and ORPHAN-CLEANUP.md documents the exception.
  • Listing pages through a new list_all_objects() helper, which raises instead of returning a partial list after 1000 pages.
  • The orphan cleanup code lives in kubernetes/features/resource_groups.py, and the label and object naming helpers it shares with compute.py moved to resources.py.

@r4victor
r4victor merged commit 6d9782f into master Nov 3, 2026
29 checks passed
@r4victor
r4victor deleted the issue_3453_kubernetes_orphan_cleanup branch November 3, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant