diff --git a/pkg/controller.v1beta1/experiment/manifest/generator.go b/pkg/controller.v1beta1/experiment/manifest/generator.go index 306f6bd9f4a..c3d0a2a14bc 100644 --- a/pkg/controller.v1beta1/experiment/manifest/generator.go +++ b/pkg/controller.v1beta1/experiment/manifest/generator.go @@ -96,7 +96,7 @@ func (g *DefaultGenerator) GetRunSpecWithHyperParameters(experiment *experiments // Convert Trial template to unstructured runSpec, err := util.ConvertStringToUnstructured(replacedTemplate) if err != nil { - return nil, fmt.Errorf("%w: %s", errConvertStringToUnstructuredFailed, err.Error()) + return nil, fmt.Errorf("%w: %w", errConvertStringToUnstructuredFailed, err) } // Set name and namespace for Run Spec @@ -118,7 +118,7 @@ func (g *DefaultGenerator) applyParameters(experiment *experimentsv1beta1.Experi if trialSpec == nil { trialSpec, err = util.ConvertStringToUnstructured(trialTemplate) if err != nil { - return "", fmt.Errorf("%w: %s", errConvertStringToUnstructuredFailed, err.Error()) + return "", fmt.Errorf("%w: %w", errConvertStringToUnstructuredFailed, err) } } @@ -205,7 +205,7 @@ func (g *DefaultGenerator) GetTrialTemplate(instance *experimentsv1beta1.Experim if trialSource.TrialSpec != nil { trialTemplateString, err = util.ConvertUnstructuredToString(trialSource.TrialSpec) if err != nil { - return "", fmt.Errorf("%w: %s", errConvertUnstructuredToStringFailed, err.Error()) + return "", fmt.Errorf("%w: %w", errConvertUnstructuredToStringFailed, err) } } else { configMapNS := trialSource.ConfigMap.ConfigMapNamespace @@ -213,7 +213,7 @@ func (g *DefaultGenerator) GetTrialTemplate(instance *experimentsv1beta1.Experim templatePath := trialSource.ConfigMap.TemplatePath configMap, err := g.client.GetConfigMap(configMapName, configMapNS) if err != nil { - return "", fmt.Errorf("%w: %v", errConfigMapNotFound, err) + return "", fmt.Errorf("%w: %w", errConfigMapNotFound, err) } var ok bool trialTemplateString, ok = configMap[templatePath] diff --git a/pkg/webhook/v1beta1/pod/inject_webhook.go b/pkg/webhook/v1beta1/pod/inject_webhook.go index b7daccd637c..fc344eac104 100644 --- a/pkg/webhook/v1beta1/pod/inject_webhook.go +++ b/pkg/webhook/v1beta1/pod/inject_webhook.go @@ -267,7 +267,7 @@ func (s *SidecarInjector) getKatibJob(object *unstructured.Unstructured, namespa // Get group and version from owner API version gv, err := schema.ParseGroupVersion(owners[i].APIVersion) if err != nil { - return "", "", fmt.Errorf("%w: %s", errInvalidOwnerAPIVersion, err.Error()) + return "", "", fmt.Errorf("%w: %w", errInvalidOwnerAPIVersion, err) } gvk := schema.GroupVersionKind{ Group: gv.Group, @@ -280,7 +280,7 @@ func (s *SidecarInjector) getKatibJob(object *unstructured.Unstructured, namespa // Nested object namespace must be equal to object namespace err = s.client.Get(context.TODO(), apitypes.NamespacedName{Name: owners[i].Name, Namespace: namespace}, nestedJob) if err != nil { - return "", "", fmt.Errorf("%w: %s", errNestedObjectNotFound, err.Error()) + return "", "", fmt.Errorf("%w: %w", errNestedObjectNotFound, err) } // Recursively search for Trial ownership in nested object jobKind, jobName, err = s.getKatibJob(nestedJob, namespace) @@ -330,7 +330,7 @@ func (s *SidecarInjector) getMetricsCollectorArgs(trial *trialsv1beta1.Trial, me suggestion := &suggestionsv1beta1.Suggestion{} err := s.client.Get(context.TODO(), apitypes.NamespacedName{Name: suggestionName, Namespace: trial.Namespace}, suggestion) if err != nil { - return nil, fmt.Errorf("%w: %s", errInvalidSuggestionName, err.Error()) + return nil, fmt.Errorf("%w: %w", errInvalidSuggestionName, err) } args = append(args, "-s-earlystop", util.GetEarlyStoppingEndpoint(suggestion)) }