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

Refactor to format VPA Updater log more efficiently #6883

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nikimanoledaki
Copy link
Contributor

@nikimanoledaki nikimanoledaki commented May 29, 2024

What type of PR is this?

Add one of the following kinds:
/kind cleanup

What this PR does / why we need it:

  • Small refactor to improve the efficiency of formatting one of the logs for VPA Updater.

Which issue(s) this PR fixes:

Follow up to #6723

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 29, 2024
@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 29, 2024
@k8s-ci-robot k8s-ci-robot requested a review from kgolab May 29, 2024 15:36
@k8s-ci-robot k8s-ci-robot requested a review from kwiesmueller May 29, 2024 15:36
@nikimanoledaki nikimanoledaki marked this pull request as ready for review May 29, 2024 15:38
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 29, 2024
@k8s-ci-robot k8s-ci-robot requested a review from voelzmo May 29, 2024 15:38
@raywainman
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 29, 2024
@raywainman
Copy link
Contributor

/assign @kwiesmueller

@Shubham82
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 30, 2024
@nikimanoledaki
Copy link
Contributor Author

Hi @kwiesmueller 👋 Added the refactor from the previous PR, let me know if it needs any changes, thank you! :)

Copy link
Member

@kwiesmueller kwiesmueller left a comment

Choose a reason for hiding this comment

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

Thanks! Just a few nits.

@@ -171,26 +171,26 @@ func (calc *UpdatePriorityCalculator) GetSortedPods(admission PodEvictionAdmissi
func (calc *UpdatePriorityCalculator) GetProcessedRecommendationTargets(r *vpa_types.RecommendedPodResources) string {
sb := &strings.Builder{}
for _, cr := range r.ContainerRecommendations {
sb.WriteString(fmt.Sprintf("%s: ", cr.ContainerName))
fmt.Fprintf(sb, "%s: ", cr.ContainerName)
Copy link
Member

Choose a reason for hiding this comment

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

Could this just be a
WriteString(name)
WriteString(: )
?

if cr.Target != nil {
sb.WriteString("target: ")
Copy link
Member

Choose a reason for hiding this comment

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

I think the WriteString here was already the most efficient way.

if !cr.Target.Memory().IsZero() {
sb.WriteString(fmt.Sprintf("%dk ", cr.Target.Memory().ScaledValue(resource.Kilo)))
fmt.Fprintf(sb, "%dk ", cr.Target.Memory().ScaledValue(resource.Kilo))
Copy link
Member

Choose a reason for hiding this comment

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

I think what I meant with my original command was that directly calling strconv.Format functions might be more efficient. Maybe that's over optimizing.
Up to you.

}
}
if cr.UncappedTarget != nil {
sb.WriteString("uncappedTarget: ")
fmt.Fprintf(sb, "uncappedTarget: ")
Copy link
Member

Choose a reason for hiding this comment

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

Same here, I think this can just be WriteString or without f.

}
}
sb.WriteString("\n")
fmt.Fprintf(sb, "\n")
Copy link
Member

Choose a reason for hiding this comment

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

Same here, I think this can be a write string or write rune

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: nikimanoledaki
Once this PR has been reviewed and has the lgtm label, please ask for approval from kwiesmueller. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 3, 2024
@Shubham82
Copy link
Contributor

Hi @nikimanoledaki, Are you working on this PR, If yes then update this PR as per the changes suggested by @kwiesmueller

@Shubham82
Copy link
Contributor

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 4, 2024
@adrianmoisey
Copy link
Member

/lgtm cancel

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 6, 2024
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 6, 2024
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vertical-pod-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants