Skip to content

Commit

Permalink
fix: delete slurm jobs if pod's state is succeeded or failed
Browse files Browse the repository at this point in the history
  • Loading branch information
d-hayashi committed Aug 27, 2024
1 parent 5e0cd2b commit 710b4b9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ func (w *watcher) fetchJobStateOnKubernetes() error {
}

for _, pod := range pods.Items {
// Filter out pods with state `Succeeded` or `Failed`
if pod.Status.Phase == "Succeeded" || pod.Status.Phase == "Failed" {
continue
}
annotations := pod.GetAnnotations()
if UUID, uuidExists := annotations["k8s-slurm-injector/uuid"]; uuidExists {
if jobId, jobIdExists := annotations["k8s-slurm-injector/jobid"]; jobIdExists {
Expand Down Expand Up @@ -201,6 +205,10 @@ func (w *watcher) fetchJobStateOnKubernetes() error {
if UUID, uuidExists := annotations["k8s-slurm-injector/uuid"]; uuidExists {
podExists := false
for _, pod := range pods.Items {
// Filter out pods with state `Succeeded` or `Failed`
if pod.Status.Phase == "Succeeded" || pod.Status.Phase == "Failed" {
continue
}
if podUUID, podUUIDExists := pod.GetAnnotations()["k8s-slurm-injector/uuid"]; podUUIDExists {
if podUUID == UUID {
podExists = true
Expand Down

0 comments on commit 710b4b9

Please sign in to comment.