Skip to content

Commit

Permalink
Fix error messages and expose underlying error.
Browse files Browse the repository at this point in the history
Error messages were incorrect regardless of which annotation was failing.

Also exposing the underlying parse error so it can actually be fixed.
  • Loading branch information
ElanHasson authored Dec 11, 2023
1 parent 844e61c commit 3c4b180
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cluster-autoscaler/cloudprovider/rancher/rancher_nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ func parseResourceAnnotations(annotations map[string]string) (corev1.ResourceLis

cpuResources, err := resource.ParseQuantity(cpu)
if err != nil {
return nil, fmt.Errorf("unable to parse cpu resources: %s", cpu)
return nil, errors.Wrap(err, fmt.Sprintf("unable to parse cpu resources: %s", cpu))
}
memory, ok := annotations[resourceMemoryAnnotation]
if !ok {
Expand All @@ -467,7 +467,7 @@ func parseResourceAnnotations(annotations map[string]string) (corev1.ResourceLis

memoryResources, err := resource.ParseQuantity(memory)
if err != nil {
return nil, fmt.Errorf("unable to parse cpu resources: %s", cpu)
return nil, errors.Wrap(err, fmt.Sprintf("unable to parse memory resources: %s", memoryResources))
}
ephemeralStorage, ok := annotations[resourceEphemeralStorageAnnotation]
if !ok {
Expand All @@ -476,7 +476,7 @@ func parseResourceAnnotations(annotations map[string]string) (corev1.ResourceLis

ephemeralStorageResources, err := resource.ParseQuantity(ephemeralStorage)
if err != nil {
return nil, fmt.Errorf("unable to parse cpu resources: %s", cpu)
return nil, errors.Wrap(fmt.Sprintf("unable to parse ephemeralStorage resources: %s", ephemeralStorageResources))
}

return corev1.ResourceList{
Expand Down

0 comments on commit 3c4b180

Please sign in to comment.