Skip to content

Commit

Permalink
Clean jobsets on delete namespace. (kubernetes-sigs#2505)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbobrovskyi authored Jul 2, 2024
1 parent 398545f commit 5c9eee9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package util

import (
"context"
"errors"
"fmt"
"io"
"time"
Expand Down Expand Up @@ -114,6 +115,9 @@ func DeleteNamespace(ctx context.Context, c client.Client, ns *corev1.Namespace)
if ns == nil {
return nil
}
if err := DeleteAllJobsetsInNamespace(ctx, c, ns); err != nil {
return err
}
if err := DeleteAllJobsInNamespace(ctx, c, ns); err != nil {
return err
}
Expand Down Expand Up @@ -146,7 +150,7 @@ func DeleteAllJobsInNamespace(ctx context.Context, c client.Client, ns *corev1.N

func DeleteAllJobsetsInNamespace(ctx context.Context, c client.Client, ns *corev1.Namespace) error {
err := c.DeleteAllOf(ctx, &jobset.JobSet{}, client.InNamespace(ns.Name), client.PropagationPolicy(metav1.DeletePropagationBackground))
if err != nil && !apierrors.IsNotFound(err) {
if err != nil && !apierrors.IsNotFound(err) && !errors.Is(err, &apimeta.NoKindMatchError{}) {
return err
}
return nil
Expand Down

0 comments on commit 5c9eee9

Please sign in to comment.