-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
Fixed statefulset PVC's capacity in kubectl description. #47573
Conversation
The output of kubectl:
|
/unassign |
/unassign @derekwaynecarr @wojtek-t |
@@ -1382,7 +1382,7 @@ func describeVolumeClaimTemplates(templates []api.PersistentVolumeClaim, w Prefi | |||
printLabelsMultilineWithIndent(w, " ", "Labels", "\t", pvc.Labels, sets.NewString()) | |||
printLabelsMultilineWithIndent(w, " ", "Annotations", "\t", pvc.Annotations, sets.NewString()) | |||
if capacity, ok := pvc.Spec.Resources.Requests[api.ResourceStorage]; ok { | |||
w.Write(LEVEL_1, "Capacity:\t%s\n", capacity) | |||
w.Write(LEVEL_1, "Capacity:\t%s\n", capacity.String()) |
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.
a better way is to change %s to %v.
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.
%v
will not work :(. Here's the output of %v
:
Capacity: {{1073741824 0} {<nil>} 1Gi BinarySI}
When we print an object by %s
in go, it'll call object's String()
; but Quantity.String()
is using pointer (for caching string), we have to call it explicitly.
Should be func (q Quantity) String() string
not func (q *Quantity) String() string
at https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go#L608 .
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.
you are right. probably worth fix the stringer interface thing. it just looks strange to explicitly call x.String()
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.
Agree. According to the comments, it use (q *Quantity) String()
for caching string, not sure the performance impact (e.g. build string every time); prefer to open an issue to trace it :).
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.
sgtm
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.
#47585 to trace the discussion.
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: k82cn, pwittrock Associated issue: 47571 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
@pwittrock , should we include this in 1.7? |
I verified this is broken on head. Fix is very low risk. Worth picking up for 1.7. See comment #47571 (comment) |
Will let @pwittrock add 1.7 milestone |
Automatic merge from submit-queue (batch tested with PRs 45268, 47573, 47632, 47818) |
What this PR does / why we need it:
We should use object instead of pointer for
String()
.Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #47571Release note: