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

Fix: do not assign an empty value to the resource (CPU or memory) if it's not defined in the container #117615

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

aheng-ch
Copy link
Contributor

@aheng-ch aheng-ch commented Apr 26, 2023

What type of PR is this?

/kind bug

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #117589

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Do not assign an empty value to the resource (CPU or memory) that not defined when stores the resources allocated to the pod in checkpoint

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


@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. 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-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 26, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @aheng-ch. 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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Apr 26, 2023
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Apr 26, 2023
@bart0sh bart0sh added this to Triage in SIG Node PR Triage Apr 26, 2023
Copy link
Member

@gjkim42 gjkim42 left a comment

Choose a reason for hiding this comment

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

Can we add some tests for this?

@gjkim42
Copy link
Member

gjkim42 commented Apr 26, 2023

/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 Apr 26, 2023
}
if _, ok := allocatedResources[v1.ResourceMemory]; ok {
c.Resources.Requests[v1.ResourceMemory] = allocatedResources[v1.ResourceMemory]
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like it's a good time to wrap this duplicated code into a function.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1. Looks good otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. PTAL @bart0sh @vinaykul

@bart0sh
Copy link
Contributor

bart0sh commented Apr 26, 2023

/triage accepted
/priority important-soon
/retest
/assign @vinaykul

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. 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 26, 2023
@bart0sh bart0sh moved this from Triage to Needs Reviewer in SIG Node PR Triage Apr 26, 2023
@bart0sh
Copy link
Contributor

bart0sh commented May 24, 2023

@aheng-ch please provide release note

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels May 24, 2023
@aheng-ch
Copy link
Contributor Author

@aheng-ch please provide release note

Added

}
if _, ok := allocatedResources[v1.ResourceMemory]; ok {
c.Resources.Requests[v1.ResourceMemory] = allocatedResources[v1.ResourceMemory]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to set requests values from checkpoint so we don't have different data in the checkpoint and in the c.Resources.Requests? Alternatively we can save/restore data to/from checkpoint in a bit smarter way so that if memory or cpu is not requested it will not be saved and restored?

Not 100% sure it makes sense, but this difference between checkpoint and memory data is a bit concerning.

@vinaykul @SergeyKanzhelev @aheng-ch WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

@bart0sh GetContainerResourceAllocation reads from checkpoint because the Requests and checkpoint values (what kubelet agreed to at a prior point) can differ. Did I miss something?

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry, this PR somehow slipped off my radar. I was thinking that some fields with nil value can be converted to empty lists before checkpointing them, so when they're read from a checkpoint we don't need to check if they're nil.

@vinaykul
Copy link
Contributor

vinaykul commented Jul 2, 2023

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 2, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 032e9c948f3e41fd47858fb472c05bc1e7851f9b

@vinaykul
Copy link
Contributor

vinaykul commented Jul 8, 2023

/test pull-kubernetes-e2e-gce-cos-alpha-features

@bart0sh
Copy link
Contributor

bart0sh commented Aug 3, 2023

/assign @mrunalp @derekwaynecarr @dchen1107

@bart0sh bart0sh moved this from Needs Reviewer to Needs Approver in SIG Node PR Triage Aug 3, 2023
@wenzhaojie
Copy link

As of now, the latest version officially released is 1.28.0. I found that as long as the feature gate of InPlacePodVPA is turned on, restarting the cluster nodes will cause the kubelet to fail to start normally. Can this pr fix this problem?

@LingyanYin
Copy link
Contributor

We used Inplace VPA in our product, and @LastNight1997 also found this issue
We reviewed the code, and it looks good cc @Jeffwan

@LastNight1997
Copy link
Contributor

We've merged this PR into our branch and it looks to be working fine in our production environment.

@wenzhaojie
Copy link

We've merged this PR into our branch and it looks to be working fine in our production environment.

What do you mean?Does this PR no longer needed?

@LastNight1997
Copy link
Contributor

@wenzhaojie No, I means that this PR is working well in our environment, and suggest it can be merged.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aheng-ch, mrunalp, vinaykul

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 23, 2023
@k8s-ci-robot k8s-ci-robot merged commit e1824b6 into kubernetes:master Oct 23, 2023
13 checks passed
SIG Node PR Triage automation moved this from Needs Approver to Done Oct 23, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.29 milestone Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. 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. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

pod_status_manager_state: checkpoint is corrupted