From 497ddecdb5294a18a684e2a3e0803e85cbe65624 Mon Sep 17 00:00:00 2001 From: googs1025 Date: Thu, 11 Apr 2024 22:25:28 +0800 Subject: [PATCH] fix: add IsNotFoundErr when get headlessSvc --- pkg/controllers/jobset_controller.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/controllers/jobset_controller.go b/pkg/controllers/jobset_controller.go index 9d0b2432..387ec5f3 100644 --- a/pkg/controllers/jobset_controller.go +++ b/pkg/controllers/jobset_controller.go @@ -27,6 +27,7 @@ import ( batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" apiequality "k8s.io/apimachinery/pkg/api/equality" + k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" @@ -552,6 +553,9 @@ func (r *JobSetReconciler) createHeadlessSvcIfNecessary(ctx context.Context, js var headlessSvc corev1.Service subdomain := GetSubdomain(js) if err := r.Get(ctx, types.NamespacedName{Name: subdomain, Namespace: js.Namespace}, &headlessSvc); err != nil { + if !k8serrors.IsNotFound(err) { + return err + } headlessSvc := corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: subdomain,