-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Conversation
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 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. |
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.
Can we add some tests for this?
/ok-to-test |
pkg/kubelet/kubelet.go
Outdated
} | ||
if _, ok := allocatedResources[v1.ResourceMemory]; ok { | ||
c.Resources.Requests[v1.ResourceMemory] = allocatedResources[v1.ResourceMemory] | ||
} | ||
} |
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.
It looks like it's a good time to wrap this duplicated code into a function.
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.
+1. Looks good otherwise.
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.
/triage accepted |
@aheng-ch please provide release note |
Added |
} | ||
if _, ok := allocatedResources[v1.ResourceMemory]; ok { | ||
c.Resources.Requests[v1.ResourceMemory] = allocatedResources[v1.ResourceMemory] | ||
} |
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.
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.
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.
@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?
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.
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.
/lgtm |
LGTM label has been added. Git tree hash: 032e9c948f3e41fd47858fb472c05bc1e7851f9b
|
/test pull-kubernetes-e2e-gce-cos-alpha-features |
/assign @mrunalp @derekwaynecarr @dchen1107 |
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? |
We used Inplace VPA in our product, and @LastNight1997 also found this issue |
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? |
@wenzhaojie No, I means that this PR is working well in our environment, and suggest it can be merged. |
[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 |
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?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: