Skip to content

Conversation

@Jeffwan
Copy link
Member

@Jeffwan Jeffwan commented Mar 14, 2024

Make In-place VPA feature work with PLEG relist. Use auxiliary runtime pod status and PLEG cache pod status to distinguish the resize pod and make sure it generate correct PLEG event and come into the event channel.

What type of PR is this?

/kind bug

What this PR does / why we need it:

Pleg doesn't handle resized pod well. See #123940 for more details

This is part of kubernetes/enhancements#4433

Which issue(s) this PR fixes:

Fixes

Special notes for your reviewer:

I have not added tests yet. I did some manual e2e tests. If the idea looks good to you, I will spend some time improving the test coverage.

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 release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 14, 2024
@Jeffwan
Copy link
Member Author

Jeffwan commented Mar 14, 2024

/sig node

@k8s-ci-robot k8s-ci-robot added sig/node Categorizes an issue or PR as relevant to SIG Node. area/kubelet and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Mar 14, 2024
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) && isPodResizeInProgress(pod, &apiPodStatus) {
// While resize is in progress, periodically call PLEG to update pod cache
runningPod := kubecontainer.ConvertPodStatusToRunningPod(kl.getRuntime().Type(), podStatus)
if err, _ := kl.pleg.UpdateCache(&runningPod, pod.UID); err != nil {
Copy link
Member Author

Choose a reason for hiding this comment

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

The only purpose of this logic was to update the cache. However, UpdateCache underneath invoke the runtime.GetPodStatus() which retrieves the latest CRI status, then the cache object stores the latest state which can not be used for state comparison in future Relist() loop.

@Jeffwan
Copy link
Member Author

Jeffwan commented Mar 14, 2024

/cc @smarterclayton @bobbypage @liggitt @kubernetes/sig-node-pr-reviews

@k8s-ci-robot
Copy link
Contributor

@Jeffwan: GitHub didn't allow me to request PR reviews from the following users: kubernetes/sig-node-pr-reviews.

Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @smarterclayton @bobbypage @liggitt @kubernetes/sig-node-pr-reviews

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.

@Jeffwan Jeffwan force-pushed the jiaxin/kep-1287-pleg-optimization branch from 8c90373 to e58fbfe Compare March 15, 2024 00:12
oldPod := g.podRecords.getOld(pid)
pod := g.podRecords.getCurrent(pid)

var cachePodStatus *kubecontainer.PodStatus
Copy link
Contributor

Choose a reason for hiding this comment

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

We would also need to calculate in the evented pleg, so make sure we don't miss it there.

Copy link
Member Author

Choose a reason for hiding this comment

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

that's a good point. I will cover it in new coming commit

@dchen1107
Copy link
Member

/assign @tallclair

@bart0sh
Copy link
Contributor

bart0sh commented Apr 5, 2024

/triage accepted
/priority important-longterm

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 5, 2024
@bart0sh
Copy link
Contributor

bart0sh commented Apr 5, 2024

@Jeffwan Please fix CI test failures, thanks.

As this is a bugfix, it would be great to get this use case covered by e2e tests.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 14, 2024
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented May 14, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: horacexd / name: Zewei Ding (74310c3)
  • ✅ login: Jeffwan / name: Jiaxin Shan (58b3c49)

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 14, 2024
newContainerStatus := podStatus.FindContainerStatusByContainerID(cid)
if oldContainerStatus != nil && newContainerStatus != nil && !containerResourceSame(oldContainerStatus.Resources, newContainerStatus.Resources) {
klog.V(5).InfoS("resize pods triggers the plegContainerUnknown event", "oldContainerStatus", oldContainerStatus, "newContainerStatus", newContainerStatus)
return generateEvents(pid, cid.ID, oldState, plegContainerUnknown)
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better to consider an edge case where a resized container has exited at the same time (newState==exited).

for i := range events {
// Filter out events that are not reliable and no other components use yet.
if events[i].Type == ContainerChanged {
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

This prevents a ContainerChangedevent from being sent when a container status is created, which is sometimes detected and converted to unknown at L99. Even if this event is sent, it doesn't seem to cause a problem at a glance. However, it would be better not to send an event when a container status is created in order to avoid any unexpected side-effects by using another event (PodSync or new one) for resizing or by checking the container status.

return
}
if pod != nil {
podStatus, err = g.runtime.GetPodStatus(ctx, pod.ID, pod.Name, pod.Namespace)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have to call it for all pods? Wouldn't it be enough to get a pod status from the runtime only when the pod is being resized (InProgress)?

@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 Aug 29, 2024
@Jeffwan
Copy link
Member Author

Jeffwan commented Sep 9, 2024

/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 9, 2024
@Jeffwan
Copy link
Member Author

Jeffwan commented Sep 9, 2024

@horacexd and I are still working on this story so remove the stale label. We will address the comments and polish the code to production grade soon.

@horacexd horacexd force-pushed the jiaxin/kep-1287-pleg-optimization branch from 1f53437 to 1700047 Compare September 9, 2024 18:35
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Sep 9, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Jeffwan
Once this PR has been reviewed and has the lgtm label, please ask for approval from tallclair. 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-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 17, 2024
Jeffwan and others added 2 commits October 21, 2024 16:36
Make In-place VPA feature work with PLEG relist. Use auxiliary runtime pod status and PLEG cache pod status to distinguish the resize pod and make sure it generate correct PLEG event and come into the event channel.

Co-authored-by: Lingyan Yin <yin.387@osu.edu>
Co-authored-by: Zewei Ding <horace.d@outlook.com>
Co-authored-by: Shengjie Xue <3150104939@zju.edu.cn>
Change-Id: I7a715b8525832f0c39ae0fa25dc42cbb3b9043f9
@horacexd horacexd force-pushed the jiaxin/kep-1287-pleg-optimization branch from 1700047 to 74310c3 Compare October 21, 2024 23:36
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 21, 2024
@k8s-ci-robot
Copy link
Contributor

@Jeffwan: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-typecheck 74310c3 link true /test pull-kubernetes-typecheck
pull-kubernetes-verify-lint 74310c3 link true /test pull-kubernetes-verify-lint
pull-kubernetes-unit 74310c3 link true /test pull-kubernetes-unit
pull-kubernetes-verify 74310c3 link true /test pull-kubernetes-verify

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

return
}
if pod != nil {
podStatus, err = g.runtime.GetPodStatus(ctx, pod.ID, pod.Name, pod.Namespace)
Copy link
Member

Choose a reason for hiding this comment

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

If I'm reading this correctly, this is going to call GetPodStatus() on every pod, on ever relist loop? Won't that make the relist too expensive? I assume the logic that made this conditional originally was intentional to avoid this.

I think this needs a lot of scale & performance testing before we can proceed with this change.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 26, 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.

@tallclair
Copy link
Member

I'm proposing an alternative approach to this in #128518

@dims dims added the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Jan 3, 2025
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and 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:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

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

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closed this PR.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and 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:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

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

/close

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/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note-none Denotes a PR that doesn't merit a release note. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Development

Successfully merging this pull request may close these issues.

10 participants