-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Conversation
Error messages were incorrect regardless of which annotation was failing. Also exposing the underlying parse error so it can actually be fixed.
Welcome @ElanHasson! |
Thanks @ElanHasson |
cc @ctrox @gajicdev @pawelkuc @thirdeyenick |
@@ -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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be good now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perfect, thanks!
Thanks @ElanHasson @ctrox |
/lgtm |
Hopefully this helps others as I've been trying to get the granular scaling stuff to work and kept seeing unable to parse "8" CPU lol. |
Hi @ctrox @Shubham82 Any word on when this can get merged? |
@towca could you please approve this PR so that it will merge? Thanks |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ctrox, ElanHasson, towca The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Error messages were incorrect regardless of which annotation was failing.
Also exposing the underlying parse error so it can actually be fixed.
Which issue(s) this PR fixes:
n/a
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: