-
Notifications
You must be signed in to change notification settings - Fork 41.6k
[FG:InPlacePodVerticalScaling] Add Pod resize complete event #130387
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
[FG:InPlacePodVerticalScaling] Add Pod resize complete event #130387
Conversation
|
|
|
Hi @shiya0705. 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-sigs/prow repository. |
|
/ok-to-test |
pkg/kubelet/kubelet.go
Outdated
|
|
||
|
|
||
| func resizeMsgGenerate(allocatedPod *v1.Pod, podStatus *kubecontainer.PodStatus) string { | ||
| var msg string = "}" |
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.
Shouldn't we just use "}" ? This might make the return value a bit weird. 🤔
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 changed code, var msg string = "}" is compared with msg = fmt.Sprintf("Pod resize complete, {") + msg
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 understand that this is not a correct way to initialize. Can we use like [] string to get msg and Join operation at the end instead of this string concatenation?
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.
Thanks for your comments, I change the string definition.
8159cfe to
1435a12
Compare
|
/retest |
313ae74 to
745bc7d
Compare
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.
this mostly LGTM. Thank you :)
/assign @tallclair
| } else { | ||
| // Verify pod resize Inprogress condition is cleared | ||
| gotResizeConditions := am.(*manager).statusManager.GetPodResizeConditions(pod.UID) | ||
| for _, c := range gotResizeConditions { |
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.
nit: Is it sufficient to check if require.Len(t, gotResizeConditions, 0)?
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.
change require.Nil(t, c.Type, "PodResizeInProgress condition type should be nil") to require.Len(t, gotResizeConditions, 0) is better,applied to the new code
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.
applied
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.
Mostly just nits
| podutil.VisitContainers(&resizedPod.Spec, podutil.InitContainers|podutil.Containers, | ||
| func(allocatedContainer *v1.Container, containerType podutil.ContainerType) bool { |
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.
(optional) podutil.ContainerIter would be a little cleaner here
| podutil.VisitContainers(&resizedPod.Spec, podutil.InitContainers|podutil.Containers, | |
| func(allocatedContainer *v1.Container, containerType podutil.ContainerType) bool { | |
| for allocatedContainer, containerType := range podutil.ContainerIter(&resizedPod.Spec, podutil.InitContainers|podutil.Containers) { |
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.
To less the modification, I Keep podutil.VisitContainers here~
|
|
||
| podutil.VisitContainers(&resizedPod.Spec, podutil.InitContainers|podutil.Containers, | ||
| func(allocatedContainer *v1.Container, containerType podutil.ContainerType) bool { | ||
| allocatedResources, exists := m.GetContainerResourceAllocation(resizedPod.UID, allocatedContainer.Name) |
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.
The pod is already using the allocated values here, so you can just use the container resources directly (allocatedResources := container.Resources). In fact, this is better, since the resize we're processing here is using a snapshot of the allocated resources, but it's possible that a new resize was admitted in parallel.
| oldPodResizeInProgressCondition: false, | ||
| expectHasResize: true, | ||
| }, { | ||
| name: "several containers", |
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.
for this case, omit some resources in each container, e.g.
- one just has CPU requests & limits
- one just has memory requests & limits
- one just has CPU & memory requests
it would also be good to add a test with init containers.
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.
Alternatively, consider adding a separate test for emitPodResizeCompletionEvent that has the more complete coverage.
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.
In order to simplify modifications, I just changed "several container" case to cover these three cases, both have init and normal container. I think it could cover the test case for emitPodResizeCompletionEvent. If there is other request
, we can add a separate func to test it.
- one just has CPU requests & limits (sidecar init container)
- one just has memory requests & limits (container)
- one just has CPU & memory requests (container)
99ef8d1 to
89cd35b
Compare
| if exists { | ||
| allocation := containerAllocation{ | ||
| Name: allocatedContainer.Name, | ||
| Resources: allocatedResources, |
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.
per Tim's suggestion (#130387 (comment)):
| Resources: allocatedResources, | |
| Resources: allocatedContainer.Resources, |
You already have the allocated container, so no need to call m.GetContainerResourceAllocation to fetch allocatedResouces.
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, I I misunderstood his meaning before, will change it.
| podResizeMsgDetailsJSON, err := json.Marshal(podResizeSource) | ||
| if err != nil { | ||
| klog.ErrorS(err, "Failed to serialize resource summary", "pod", format.Pod(allocatedPod)) | ||
| return "Pod resize completed: " |
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.
| return "Pod resize completed: " | |
| return "Pod resize completed" |
why the :? Are we expecting something to be appended to this in the error case?
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.
No, you are correct, I deleted it
|
/test pull-kubernetes-unit-windows-master |
|
Don't worry about the failing windows test, it's failing on one of my PRs too so I think it is unrelated, and it won't block the PR from merging. Ping me when you push your changes, will do a final pass |
a541808 to
3a2ea0e
Compare
3a2ea0e to
2256f57
Compare
|
@natasha41575 Thank you so much, I have changed and pushed the code, please help to check |
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 label has been added. Git tree hash: cc823c76e3632ab9e2fa0dcae676666135165dd1
|
|
@shiya0705: The following tests failed, say
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. |
|
/approve +1 for what Natasha said, thanks for being patient and sticking with this! |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: shiya0705, tallclair 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 |
|
/retest-required |
|
@tallclair @natasha41575 Thank you so much for your patient review and feedback. I've learned a lot from all of you. Hope to make more contribution to this feature. |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Add events when pod resize complete
Which issue(s) this PR fixes:
Fixes #127172
Special notes for your reviewer:
N/A
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
N/A
Does this PR introduce a user-facing change?
Event is a user-facing change