Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rancher: Fix error messages and expose underlying error. #6363

Merged
merged 5 commits into from
Jan 15, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, fmt.Errorf("unable to parse cpu resources: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we still include the string cpu in the error message in addition to err? That might also give a hint why the parsing has failed. Same goes for the other errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

I'm not following..CPU is in the error for CPU?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the variable cpu a few lines above:

cpu, ok := annotations[resourceCPUAnnotation]

If it can't be parsed by resource.ParseQuantity(cpu), it would be helpful if the error message would contain the value. So the error would be something like:

fmt.Errorf("unable to parse cpu resources from %q: %w", cpu, err)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, yeah 👍🏻
I thought you meant the literal string 'cpu', which is what I removed previously for non-CPU values.

Wilo fix shortly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect, thanks!

}
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, fmt.Errorf("unable to parse memory resources: %w", err)
}
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, fmt.Errorf("unable to parse ephemeralStorage resources: %w", err)
}

return corev1.ResourceList{
Expand Down
Loading