Skip to content

Commit

Permalink
Reformatted as wrapped errors
Browse files Browse the repository at this point in the history
Signed-off-by: tariq-hasan <[email protected]>
  • Loading branch information
tariq-hasan committed Apr 11, 2024
1 parent efcafb8 commit e0518ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions pkg/controller.v1beta1/experiment/manifest/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
}

Expand Down Expand Up @@ -205,15 +205,15 @@ 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
configMapName := trialSource.ConfigMap.ConfigMapName
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]
Expand Down
6 changes: 3 additions & 3 deletions pkg/webhook/v1beta1/pod/inject_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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))
}
Expand Down

0 comments on commit e0518ac

Please sign in to comment.