From d780a668a107345f9284dfc0afe68471dcd3288c Mon Sep 17 00:00:00 2001 From: Praveen Jaya Kumar Date: Wed, 25 Mar 2026 17:53:48 +0530 Subject: [PATCH 1/5] fix the since and sinceTime validation --- api/v1alpha1/mustgather_types.go | 12 +++-- .../operator.openshift.io_mustgathers.yaml | 13 +++++- controllers/mustgather/constant.go | 3 ++ .../mustgather/mustgather_controller.go | 18 +++++++- .../mustgather/mustgather_controller_test.go | 45 +++++++++++++++++++ .../operator.openshift.io_mustgathers.yaml | 15 +++++-- 6 files changed, 96 insertions(+), 10 deletions(-) diff --git a/api/v1alpha1/mustgather_types.go b/api/v1alpha1/mustgather_types.go index c3bb90832..fc2d5a82d 100644 --- a/api/v1alpha1/mustgather_types.go +++ b/api/v1alpha1/mustgather_types.go @@ -71,6 +71,9 @@ type MustGatherSpec struct { // GatherSpec allows specifying the execution details for a must-gather run and the collection behavior. // +kubebuilder:validation:XValidation:rule="!(has(self.since) && has(self.sinceTime))",message="only one of since or sinceTime may be specified" +// +kubebuilder:validation:XValidation:rule="!has(self.since) || !self.since.startsWith(\"-\")",message="since must be a non-negative duration string" +// +kubebuilder:validation:XValidation:rule="!has(self.since) || self.since.startsWith(\"-\") || self.since.matches(r'^\\+?(([0-9]+(\\.[0-9]*)?|\\.[0-9]+)(ns|µs|us|ms|s|m|h))+$')",message="since may only use these duration suffixes: ns, us, µs, ms, s, m, h (e.g. 2h, 30m, 168h for one week)." +// +kubebuilder:validation:XValidation:rule="!has(self.sinceTime) || self.sinceTime.matches(r'^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$')",message="sinceTime must be in RFC3339 format." type GatherSpec struct { // +kubebuilder:validation:Optional // Audit requests audit log collection via the default gather entrypoint. @@ -90,18 +93,19 @@ type GatherSpec struct { // +kubebuilder:validation:Items:MaxLength=256 Args []string `json:"args,omitempty"` - // Since only returns logs newer than a relative duration like "2h" or "30m". + // Since only returns logs newer than a relative duration (e.g. 2h, 30m, 168h for one week). Must be non-negative. + // Allowed units are ns, us, µs, ms, s, m, and h. // This is passed to the must-gather script to filter log collection. // Only one of since or sinceTime may be specified. // +kubebuilder:validation:Optional - // +kubebuilder:validation:Format=duration Since *metav1.Duration `json:"since,omitempty"` - // SinceTime only returns logs after a specific date/time (RFC3339 format). + // SinceTime only returns logs after a specific instant. Use RFC3339 with uppercase T and Z or a zone offset + // (e.g. 2026-02-02T00:00:00Z). Must not be after the current time when the operator reconciles the MustGather + // (CRD CEL cannot access metadata.creationTimestamp or a wall clock; validation is done in the controller). // This is passed to the must-gather script to filter log collection. // Only one of since or sinceTime may be specified. // +kubebuilder:validation:Optional - // +kubebuilder:validation:Format=date-time SinceTime *metav1.Time `json:"sinceTime,omitempty"` } diff --git a/bundle/manifests/tech-preview/operator.openshift.io_mustgathers.yaml b/bundle/manifests/tech-preview/operator.openshift.io_mustgathers.yaml index 4bf3925e4..c3240deb7 100644 --- a/bundle/manifests/tech-preview/operator.openshift.io_mustgathers.yaml +++ b/bundle/manifests/tech-preview/operator.openshift.io_mustgathers.yaml @@ -68,14 +68,17 @@ spec: type: array since: description: |- - Since only returns logs newer than a relative duration like "2h" or "30m". + Since only returns logs newer than a relative duration (e.g. 2h, 30m, 168h for one week). Must be non-negative. + Allowed units are ns, us, µs, ms, s, m, and h. This is passed to the must-gather script to filter log collection. Only one of since or sinceTime may be specified. format: duration type: string sinceTime: description: |- - SinceTime only returns logs after a specific date/time (RFC3339 format). + SinceTime only returns logs after a specific instant. Use RFC3339 with uppercase T and Z or a zone offset + (e.g. 2026-02-02T00:00:00Z). Must not be after the current time when the operator reconciles the MustGather + (CRD CEL cannot access metadata.creationTimestamp or a wall clock; validation is done in the controller). This is passed to the must-gather script to filter log collection. Only one of since or sinceTime may be specified. format: date-time @@ -84,6 +87,12 @@ spec: x-kubernetes-validations: - message: only one of since or sinceTime may be specified rule: '!(has(self.since) && has(self.sinceTime))' + - message: since must be a non-negative duration string + rule: '!has(self.since) || !self.since.startsWith("-")' + - message: 'since may only use these duration suffixes: ns, us, µs, ms, s, m, h (e.g. 2h, 30m, 168h for one week).' + rule: "!has(self.since) || self.since.startsWith(\"-\") || self.since.matches(r'^\\+?(([0-9]+(\\.[0-9]*)?|\\.[0-9]+)(ns|µs|us|ms|s|m|h))+$')" + - message: sinceTime must be in RFC3339 format. + rule: "!has(self.sinceTime) || self.sinceTime.matches(r'^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$')" imageStreamRef: description: |- ImageStreamRef specifies a custom image from the allowlist to be used for the diff --git a/controllers/mustgather/constant.go b/controllers/mustgather/constant.go index 5703caee9..8c3a0171d 100644 --- a/controllers/mustgather/constant.go +++ b/controllers/mustgather/constant.go @@ -20,6 +20,9 @@ const ( // ValidationImageStream represents the validation type for ImageStream ValidationImageStream = "ImageStream" + // ValidationSinceTime represents validation of gatherSpec.sinceTime (e.g. must not be in the future) + ValidationSinceTime = "sinceTime" + // DefaultMustGatherImageEnv represents the environment variable for the default must-gather image DefaultMustGatherImageEnv = "DEFAULT_MUST_GATHER_IMAGE" diff --git a/controllers/mustgather/mustgather_controller.go b/controllers/mustgather/mustgather_controller.go index 44a052fbd..246e8b628 100644 --- a/controllers/mustgather/mustgather_controller.go +++ b/controllers/mustgather/mustgather_controller.go @@ -22,6 +22,7 @@ import ( "fmt" "os" "slices" + "time" "github.com/go-logr/logr" imagev1 "github.com/openshift/api/image/v1" @@ -50,6 +51,10 @@ const ( var log = logf.Log.WithName(ControllerName) +// errValidationFailureHandled is returned when setValidationFailureStatus succeeded so Reconcile +// must not call ManageError (which would replace status conditions and confuse validation output). +var errValidationFailureHandled = goerror.New("mustgather: validation failure recorded in status") + // blank assignment to verify that MustGatherReconciler implements reconcile.Reconciler var _ reconcile.Reconciler = &MustGatherReconciler{} @@ -156,6 +161,9 @@ func (r *MustGatherReconciler) Reconcile(ctx context.Context, request reconcile. job, err := r.getJobFromInstance(ctx, instance) if err != nil { + if goerror.Is(err, errValidationFailureHandled) { + return reconcile.Result{}, nil + } log.Error(err, "unable to get job from", "instance", instance) return r.ManageError(ctx, instance, err) } @@ -386,7 +394,7 @@ func (r *MustGatherReconciler) getJobFromInstance(ctx context.Context, instance if validationErr != nil { return nil, fmt.Errorf("failed to set validation failure status for original error %v: %w", err, validationErr) } - return nil, err + return nil, fmt.Errorf("%w: %v", errValidationFailureHandled, err) } // Inject the operator image URI from the pod's env variables @@ -397,6 +405,14 @@ func (r *MustGatherReconciler) getJobFromInstance(ctx context.Context, instance return nil, err } + if instance.Spec.GatherSpec != nil && instance.Spec.GatherSpec.SinceTime != nil && instance.Spec.GatherSpec.SinceTime.After(time.Now()) { + err := fmt.Errorf("gatherSpec.sinceTime must be at or before the current date and time") + if _, validationErr := r.setValidationFailureStatus(ctx, log, instance, ValidationSinceTime, err); validationErr != nil { + return nil, fmt.Errorf("failed to set validation failure status: %w, %w", err, validationErr) + } + return nil, fmt.Errorf("%w: %v", errValidationFailureHandled, err) + } + return getJobTemplate(image, operatorImage, *instance, r.TrustedCAConfigMap), nil } diff --git a/controllers/mustgather/mustgather_controller_test.go b/controllers/mustgather/mustgather_controller_test.go index 0191c26e8..736b2fb23 100644 --- a/controllers/mustgather/mustgather_controller_test.go +++ b/controllers/mustgather/mustgather_controller_test.go @@ -1588,6 +1588,51 @@ func generateFakeClient(objs ...runtime.Object) (client.Client, *runtime.Scheme) return cl, s } +func TestGetJobFromInstanceFutureSinceTimeSetsValidationStatus(t *testing.T) { + st := metav1.NewTime(time.Now().Add(48 * time.Hour)) + mg := &mustgatherv1alpha1.MustGather{ + ObjectMeta: metav1.ObjectMeta{ + Name: "mg-future-sincetime", + Namespace: "openshift-must-gather-operator", + Finalizers: []string{mustGatherFinalizer}, + }, + Spec: mustgatherv1alpha1.MustGatherSpec{ + GatherSpec: &mustgatherv1alpha1.GatherSpec{ + SinceTime: &st, + }, + }, + } + t.Setenv("OPERATOR_IMAGE", "test-image") + t.Setenv("DEFAULT_MUST_GATHER_IMAGE", "test-must-gather-image") + cl, s := generateFakeClient(mg) + eventRec := record.NewFakeRecorder(10) + var cfg *rest.Config + r := MustGatherReconciler{ + ReconcilerBase: util.NewReconcilerBase(cl, s, cfg, eventRec, nil), + DefaultMustGatherImage: "test-must-gather-image", + OperatorNamespace: "openshift-must-gather-operator", + } + + _, err := r.getJobFromInstance(context.Background(), mg) + if err == nil { + t.Fatal("expected error") + } + if !errors.Is(err, errValidationFailureHandled) { + t.Fatalf("expected errValidationFailureHandled, got %v", err) + } + + updated := &mustgatherv1alpha1.MustGather{} + if err := cl.Get(context.Background(), types.NamespacedName{Name: mg.Name, Namespace: mg.Namespace}, updated); err != nil { + t.Fatal(err) + } + if updated.Status.Status != "Failed" { + t.Fatalf("expected status Failed, got %q", updated.Status.Status) + } + if !strings.Contains(updated.Status.Reason, ValidationSinceTime) { + t.Fatalf("expected reason to mention sinceTime, got %q", updated.Status.Reason) + } +} + // TestSFTPCredentialValidation tests the credential validation logic added in the controller func TestSFTPCredentialValidation(t *testing.T) { // Setup scheme diff --git a/deploy/crds/operator.openshift.io_mustgathers.yaml b/deploy/crds/operator.openshift.io_mustgathers.yaml index 4bf3925e4..b4b5b5380 100644 --- a/deploy/crds/operator.openshift.io_mustgathers.yaml +++ b/deploy/crds/operator.openshift.io_mustgathers.yaml @@ -68,14 +68,16 @@ spec: type: array since: description: |- - Since only returns logs newer than a relative duration like "2h" or "30m". + Since only returns logs newer than a relative duration (e.g. 2h, 30m, 168h for one week). Must be non-negative. + Allowed units are ns, us, µs, ms, s, m, and h. This is passed to the must-gather script to filter log collection. Only one of since or sinceTime may be specified. - format: duration type: string sinceTime: description: |- - SinceTime only returns logs after a specific date/time (RFC3339 format). + SinceTime only returns logs after a specific instant. Use RFC3339 with uppercase T and Z or a zone offset + (e.g. 2026-02-02T00:00:00Z). Must not be after the current time when the operator reconciles the MustGather + (CRD CEL cannot access metadata.creationTimestamp or a wall clock; validation is done in the controller). This is passed to the must-gather script to filter log collection. Only one of since or sinceTime may be specified. format: date-time @@ -84,6 +86,13 @@ spec: x-kubernetes-validations: - message: only one of since or sinceTime may be specified rule: '!(has(self.since) && has(self.sinceTime))' + - message: since must be a non-negative duration string + rule: '!has(self.since) || !self.since.startsWith("-")' + - message: 'since may only use these duration suffixes: ns, us, µs, + ms, s, m, h (e.g. 2h, 30m, 168h for one week).' + rule: '!has(self.since) || self.since.startsWith("-") || self.since.matches(r''^\+?(([0-9]+(\.[0-9]*)?|\.[0-9]+)(ns|µs|us|ms|s|m|h))+$'')' + - message: sinceTime must be in RFC3339 format. + rule: '!has(self.sinceTime) || self.sinceTime.matches(r''^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$'')' imageStreamRef: description: |- ImageStreamRef specifies a custom image from the allowlist to be used for the From 05a4b4b2fc592b5c9e05521d238ad4943d722993 Mon Sep 17 00:00:00 2001 From: Praveen Jaya Kumar Date: Thu, 9 Apr 2026 10:07:33 +0530 Subject: [PATCH 2/5] fix the validation error --- api/v1alpha1/mustgather_types.go | 2 +- .../tech-preview/operator.openshift.io_mustgathers.yaml | 5 +++-- deploy/crds/operator.openshift.io_mustgathers.yaml | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api/v1alpha1/mustgather_types.go b/api/v1alpha1/mustgather_types.go index fc2d5a82d..5442be5ff 100644 --- a/api/v1alpha1/mustgather_types.go +++ b/api/v1alpha1/mustgather_types.go @@ -72,7 +72,7 @@ type MustGatherSpec struct { // GatherSpec allows specifying the execution details for a must-gather run and the collection behavior. // +kubebuilder:validation:XValidation:rule="!(has(self.since) && has(self.sinceTime))",message="only one of since or sinceTime may be specified" // +kubebuilder:validation:XValidation:rule="!has(self.since) || !self.since.startsWith(\"-\")",message="since must be a non-negative duration string" -// +kubebuilder:validation:XValidation:rule="!has(self.since) || self.since.startsWith(\"-\") || self.since.matches(r'^\\+?(([0-9]+(\\.[0-9]*)?|\\.[0-9]+)(ns|µs|us|ms|s|m|h))+$')",message="since may only use these duration suffixes: ns, us, µs, ms, s, m, h (e.g. 2h, 30m, 168h for one week)." +// +kubebuilder:validation:XValidation:rule="!has(self.since) || self.since.matches(r'^\\+?(([0-9]+(\\.[0-9]*)?|\\.[0-9]+)(ns|µs|us|ms|s|m|h))+$')",message="since may only use these duration suffixes: ns, us, µs, ms, s, m, h (e.g. 2h, 30m, 168h for one week)." // +kubebuilder:validation:XValidation:rule="!has(self.sinceTime) || self.sinceTime.matches(r'^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$')",message="sinceTime must be in RFC3339 format." type GatherSpec struct { // +kubebuilder:validation:Optional diff --git a/bundle/manifests/tech-preview/operator.openshift.io_mustgathers.yaml b/bundle/manifests/tech-preview/operator.openshift.io_mustgathers.yaml index c3240deb7..66b2e718a 100644 --- a/bundle/manifests/tech-preview/operator.openshift.io_mustgathers.yaml +++ b/bundle/manifests/tech-preview/operator.openshift.io_mustgathers.yaml @@ -89,8 +89,9 @@ spec: rule: '!(has(self.since) && has(self.sinceTime))' - message: since must be a non-negative duration string rule: '!has(self.since) || !self.since.startsWith("-")' - - message: 'since may only use these duration suffixes: ns, us, µs, ms, s, m, h (e.g. 2h, 30m, 168h for one week).' - rule: "!has(self.since) || self.since.startsWith(\"-\") || self.since.matches(r'^\\+?(([0-9]+(\\.[0-9]*)?|\\.[0-9]+)(ns|µs|us|ms|s|m|h))+$')" + - message: 'since may only use these duration suffixes: ns, us, µs, + ms, s, m, h (e.g. 2h, 30m, 168h for one week).' + rule: '!has(self.since) || self.since.matches(r''^\+?(([0-9]+(\.[0-9]*)?|\.[0-9]+)(ns|µs|us|ms|s|m|h))+$'')' - message: sinceTime must be in RFC3339 format. rule: "!has(self.sinceTime) || self.sinceTime.matches(r'^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$')" imageStreamRef: diff --git a/deploy/crds/operator.openshift.io_mustgathers.yaml b/deploy/crds/operator.openshift.io_mustgathers.yaml index b4b5b5380..1dbcb14b9 100644 --- a/deploy/crds/operator.openshift.io_mustgathers.yaml +++ b/deploy/crds/operator.openshift.io_mustgathers.yaml @@ -90,7 +90,7 @@ spec: rule: '!has(self.since) || !self.since.startsWith("-")' - message: 'since may only use these duration suffixes: ns, us, µs, ms, s, m, h (e.g. 2h, 30m, 168h for one week).' - rule: '!has(self.since) || self.since.startsWith("-") || self.since.matches(r''^\+?(([0-9]+(\.[0-9]*)?|\.[0-9]+)(ns|µs|us|ms|s|m|h))+$'')' + rule: '!has(self.since) || self.since.matches(r''^\+?(([0-9]+(\.[0-9]*)?|\.[0-9]+)(ns|µs|us|ms|s|m|h))+$'')' - message: sinceTime must be in RFC3339 format. rule: '!has(self.sinceTime) || self.sinceTime.matches(r''^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$'')' imageStreamRef: From 05e12a7e6398adeb611dcde9212f13868999f5a5 Mon Sep 17 00:00:00 2001 From: Praveen Jaya Kumar Date: Thu, 9 Apr 2026 20:33:41 +0530 Subject: [PATCH 3/5] remove unnecessary descriptions --- api/v1alpha1/mustgather_types.go | 3 +-- .../tech-preview/operator.openshift.io_mustgathers.yaml | 3 +-- deploy/crds/operator.openshift.io_mustgathers.yaml | 5 +---- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/api/v1alpha1/mustgather_types.go b/api/v1alpha1/mustgather_types.go index 5442be5ff..189d2ffa5 100644 --- a/api/v1alpha1/mustgather_types.go +++ b/api/v1alpha1/mustgather_types.go @@ -101,8 +101,7 @@ type GatherSpec struct { Since *metav1.Duration `json:"since,omitempty"` // SinceTime only returns logs after a specific instant. Use RFC3339 with uppercase T and Z or a zone offset - // (e.g. 2026-02-02T00:00:00Z). Must not be after the current time when the operator reconciles the MustGather - // (CRD CEL cannot access metadata.creationTimestamp or a wall clock; validation is done in the controller). + // (e.g. 2026-02-02T00:00:00Z). Must not be after the current time. // This is passed to the must-gather script to filter log collection. // Only one of since or sinceTime may be specified. // +kubebuilder:validation:Optional diff --git a/bundle/manifests/tech-preview/operator.openshift.io_mustgathers.yaml b/bundle/manifests/tech-preview/operator.openshift.io_mustgathers.yaml index 66b2e718a..95c28224d 100644 --- a/bundle/manifests/tech-preview/operator.openshift.io_mustgathers.yaml +++ b/bundle/manifests/tech-preview/operator.openshift.io_mustgathers.yaml @@ -77,8 +77,7 @@ spec: sinceTime: description: |- SinceTime only returns logs after a specific instant. Use RFC3339 with uppercase T and Z or a zone offset - (e.g. 2026-02-02T00:00:00Z). Must not be after the current time when the operator reconciles the MustGather - (CRD CEL cannot access metadata.creationTimestamp or a wall clock; validation is done in the controller). + (e.g. 2026-02-02T00:00:00Z). Must not be after the current time. This is passed to the must-gather script to filter log collection. Only one of since or sinceTime may be specified. format: date-time diff --git a/deploy/crds/operator.openshift.io_mustgathers.yaml b/deploy/crds/operator.openshift.io_mustgathers.yaml index 1dbcb14b9..c30e2f4ae 100644 --- a/deploy/crds/operator.openshift.io_mustgathers.yaml +++ b/deploy/crds/operator.openshift.io_mustgathers.yaml @@ -70,15 +70,12 @@ spec: description: |- Since only returns logs newer than a relative duration (e.g. 2h, 30m, 168h for one week). Must be non-negative. Allowed units are ns, us, µs, ms, s, m, and h. - This is passed to the must-gather script to filter log collection. Only one of since or sinceTime may be specified. type: string sinceTime: description: |- SinceTime only returns logs after a specific instant. Use RFC3339 with uppercase T and Z or a zone offset - (e.g. 2026-02-02T00:00:00Z). Must not be after the current time when the operator reconciles the MustGather - (CRD CEL cannot access metadata.creationTimestamp or a wall clock; validation is done in the controller). - This is passed to the must-gather script to filter log collection. + (e.g. 2026-02-02T00:00:00Z). Must not be after the current time. Only one of since or sinceTime may be specified. format: date-time type: string From d4fa6240d32564a7f11d8462ce0456a214157a0f Mon Sep 17 00:00:00 2001 From: Praveen Jaya Kumar Date: Wed, 6 May 2026 12:47:43 +0530 Subject: [PATCH 4/5] remove the duration format --- .../tech-preview/operator.openshift.io_mustgathers.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/bundle/manifests/tech-preview/operator.openshift.io_mustgathers.yaml b/bundle/manifests/tech-preview/operator.openshift.io_mustgathers.yaml index 95c28224d..8d395ef13 100644 --- a/bundle/manifests/tech-preview/operator.openshift.io_mustgathers.yaml +++ b/bundle/manifests/tech-preview/operator.openshift.io_mustgathers.yaml @@ -72,7 +72,6 @@ spec: Allowed units are ns, us, µs, ms, s, m, and h. This is passed to the must-gather script to filter log collection. Only one of since or sinceTime may be specified. - format: duration type: string sinceTime: description: |- From 43973998d63585bf9f98cc7413567d4ecdd78ff5 Mon Sep 17 00:00:00 2001 From: Praveen Jaya Kumar Date: Wed, 6 May 2026 16:40:35 +0530 Subject: [PATCH 5/5] Remove errValidationFailureHandled --- controllers/mustgather/mustgather_controller.go | 11 ++--------- controllers/mustgather/mustgather_controller_test.go | 3 --- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/controllers/mustgather/mustgather_controller.go b/controllers/mustgather/mustgather_controller.go index 246e8b628..db888195f 100644 --- a/controllers/mustgather/mustgather_controller.go +++ b/controllers/mustgather/mustgather_controller.go @@ -51,10 +51,6 @@ const ( var log = logf.Log.WithName(ControllerName) -// errValidationFailureHandled is returned when setValidationFailureStatus succeeded so Reconcile -// must not call ManageError (which would replace status conditions and confuse validation output). -var errValidationFailureHandled = goerror.New("mustgather: validation failure recorded in status") - // blank assignment to verify that MustGatherReconciler implements reconcile.Reconciler var _ reconcile.Reconciler = &MustGatherReconciler{} @@ -161,9 +157,6 @@ func (r *MustGatherReconciler) Reconcile(ctx context.Context, request reconcile. job, err := r.getJobFromInstance(ctx, instance) if err != nil { - if goerror.Is(err, errValidationFailureHandled) { - return reconcile.Result{}, nil - } log.Error(err, "unable to get job from", "instance", instance) return r.ManageError(ctx, instance, err) } @@ -394,7 +387,7 @@ func (r *MustGatherReconciler) getJobFromInstance(ctx context.Context, instance if validationErr != nil { return nil, fmt.Errorf("failed to set validation failure status for original error %v: %w", err, validationErr) } - return nil, fmt.Errorf("%w: %v", errValidationFailureHandled, err) + return nil, err } // Inject the operator image URI from the pod's env variables @@ -410,7 +403,7 @@ func (r *MustGatherReconciler) getJobFromInstance(ctx context.Context, instance if _, validationErr := r.setValidationFailureStatus(ctx, log, instance, ValidationSinceTime, err); validationErr != nil { return nil, fmt.Errorf("failed to set validation failure status: %w, %w", err, validationErr) } - return nil, fmt.Errorf("%w: %v", errValidationFailureHandled, err) + return nil, err } return getJobTemplate(image, operatorImage, *instance, r.TrustedCAConfigMap), nil diff --git a/controllers/mustgather/mustgather_controller_test.go b/controllers/mustgather/mustgather_controller_test.go index 736b2fb23..c51637ef8 100644 --- a/controllers/mustgather/mustgather_controller_test.go +++ b/controllers/mustgather/mustgather_controller_test.go @@ -1617,9 +1617,6 @@ func TestGetJobFromInstanceFutureSinceTimeSetsValidationStatus(t *testing.T) { if err == nil { t.Fatal("expected error") } - if !errors.Is(err, errValidationFailureHandled) { - t.Fatalf("expected errValidationFailureHandled, got %v", err) - } updated := &mustgatherv1alpha1.MustGather{} if err := cl.Get(context.Background(), types.NamespacedName{Name: mg.Name, Namespace: mg.Namespace}, updated); err != nil {