-
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
Add more precise logging for VPA resource recommendations #6723
Add more precise logging for VPA resource recommendations #6723
Conversation
Welcome @nikimanoledaki! |
Hi @nikimanoledaki. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
/test |
@nikimanoledaki: The
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
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.
Hey @nikimanoledaki thanks for the PR!
A few thoughts:
- do you care about all the recommendation values including the bounds? I guess given the issue at hand, we only really care about
target
anduncappedTarget
(it might be interesting to see what the recommendation would be withoutminAllowed
). So maybe let's removeupperBound
andlowerBound
here to reduce noise - As the format string you're re-using doesn't have a placeholder for the recommendations, they're inserted at the end with this ugly
!(EXTRA
stuff. Maybe you could put a proper placeholder in the format string - It might be the simplest solution to add a
String()
method to* RecommendedPodResources
similar to this one (note that this doesn't account for anynil
values yet)
func (r *RecommendedPodResources) String() string {
sb := &strings.Builder{}
for _, cr := range r.ContainerRecommendations {
sb.WriteString(fmt.Sprintf("%s: [ target: %sK, %vm; uncappedTarget: %sK, %vm ]\n", cr.ContainerName, cr.Target.Memory().AsDec(), cr.Target.Cpu().MilliValue(), cr.UncappedTarget.Memory().AsDec(), cr.UncappedTarget.Cpu().MilliValue()))
}
return sb.String()
}
- Do we maybe want to add additional logging for that issue? I was integrating Add logging in case we have minimum memory recommendations gardener/autoscaler#299 into our fork to debug why recommender would give so low recommendations, even when the workload had been running for a long time. In theory, the in-memory model should be backfilled from the
VPACheckpoint
, such that even a small period with non-existing memory samples (caused e.g. by theKeyError
that you observed) should not lead to recommendations belowminAllowed
.
I really appreciate that you're putting work into this!
vertical-pod-autoscaler/pkg/updater/priority/update_priority_calculator.go
Outdated
Show resolved
Hide resolved
Hi @voelzmo thank you so much for your review! Apologies for the long delay in getting back to this. Responding to your feedback as soon as possible, first thing tomorrow. I needed to wrap up a few other things and finally made time to get back into this. Thank you for your understanding! |
/retest |
vertical-pod-autoscaler/pkg/updater/priority/update_priority_calculator.go
Outdated
Show resolved
Hide resolved
This looks very good to me! We now have one remaining linter error, that's why the
|
vertical-pod-autoscaler/pkg/updater/priority/update_priority_calculator.go
Outdated
Show resolved
Hide resolved
9e8f445
to
1800a6e
Compare
if cr.Target != nil { | ||
sb.WriteString("target: ") | ||
if !cr.Target.Memory().IsZero() { | ||
sb.WriteString(fmt.Sprintf("%sK ", cr.Target.Memory().AsDec())) |
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 think we need to scale this in order to be Kilobytes, otherwise AsDec()
returns the memory value in Bytes
sb.WriteString(fmt.Sprintf("%sK ", cr.Target.Memory().AsDec())) | |
sb.WriteString(fmt.Sprintf("%sk ", cr.Target.Memory().ScaledValue(resource.Kilo))) |
whereas resource
is imported from
"k8s.io/apimachinery/pkg/api/resource"
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.
Good point - added this in the latest commit + updated the tests!
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.
/lgtm
@kwiesmueller this looks good from my side and will hopefully help investigating a long-standing issue. Can you please approve? Thanks! |
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.
Just a nit that the string building could be done without fmt which might be more efficient. (using the string builder directly and strconv).
Otherwise lgtm
/assign @raywainman
func (calc *UpdatePriorityCalculator) GetProcessedRecommendationTargets(r *vpa_types.RecommendedPodResources) string { | ||
sb := &strings.Builder{} | ||
for _, cr := range r.ContainerRecommendations { | ||
sb.WriteString(fmt.Sprintf("%s: ", cr.ContainerName)) |
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.
As you're already using the string builder here you could write this without fmt.Sprintf to be more efficient.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kwiesmueller, nikimanoledaki, voelzmo 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 |
Oh well, I guess I should have done a hold if I cared more about the nit. |
@nikimanoledaki up to you if you want to follow up with another PR to reply to the nit |
@kwiesmueller thank you - agreed that it would be nice to make it more efficient! Opened a PR: #6883 |
What type of PR is this?
/kind documentation
What this PR does / why we need it:
This PR adds more precise logging for VPA recommendations.
processedRecommendation
from the VPA Updater, specifically, the capped and uncapped target resources (CPU/mem).Which issue(s) this PR fixes:
Helps to debug #6705
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: