-
Notifications
You must be signed in to change notification settings - Fork 768
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
feat: enhanced in-place update module to support vertical scaling #1353
base: master
Are you sure you want to change the base?
feat: enhanced in-place update module to support vertical scaling #1353
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
Sonatype Lift is retiringSonatype Lift will be retiring on Sep 12, 2023, with its analysis stopping on Aug 12, 2023. We understand that this news may come as a disappointment, and Sonatype is committed to helping you transition off it seamlessly. If you’d like to retain your data, please export your issues from the web console. |
08c47c7
to
04b5eb8
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1353 +/- ##
==========================================
+ Coverage 47.91% 50.22% +2.30%
==========================================
Files 162 193 +31
Lines 23491 24908 +1417
==========================================
+ Hits 11256 12509 +1253
- Misses 11014 11113 +99
- Partials 1221 1286 +65
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
0470ce2
to
4e13c0d
Compare
35c4939
to
28406cb
Compare
48126ff
to
aca435f
Compare
The complete logic needs to wait until the k8s api of kruise is upgraded. |
/hold |
aca435f
to
d064af1
Compare
d064af1
to
cbd728f
Compare
3f4af6f
to
a12055b
Compare
I encountered two errors while adding e2e test cases:
|
a12055b
to
eea019c
Compare
6339a56
to
d0db898
Compare
@@ -344,6 +401,11 @@ func defaultCalculateInPlaceUpdateSpec(oldRevision, newRevision *apps.Controller | |||
} | |||
updateSpec.MetaDataPatch = patchBytes | |||
} | |||
// Need to distinguish whether only resources have been updated | |||
if len(updateSpec.ContainerResources) > 0 && len(updateSpec.ContainerImages) == 0 && !updateSpec.UpdateEnvFromMetadata { | |||
updateSpec.VerticalUpdateOnly = true |
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 seems that one can infer the VerticalUpdateOnly using ContainerResources, ContainerImages and UpdateEnvFromMetadata, so VerticalUpdateOnly is not necessary, consider change the field VerticalUpdateOnly to a function
// UpdateResource implements vertical updates by directly modifying the container's resources, | ||
// conforming to the k8s community standard | ||
func (v *VerticalUpdate) UpdateContainerResource(container *v1.Container, newResource *v1.ResourceRequirements) { | ||
if container == nil || newResource == nil { |
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.
we can not return directly since it is possible to set or unset container resource for a pod of burstable qos class
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.
We should recreate pod when try to change qos class.
// 7. empty exist exist => this container is not inplace-updated by kruise, ignore | ||
func (v *VerticalUpdate) IsContainerUpdateCompleted(pod *v1.Pod, container *v1.Container, containerStatus *v1.ContainerStatus, lastContainerStatus appspub.InPlaceUpdateContainerStatus) bool { | ||
// case 5-7 | ||
if lastContainerStatus.Resources.Limits == nil && lastContainerStatus.Resources.Requests == nil { |
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 simply check pod.status.resize, if the field is not empty, the update is not 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.
When we only resize limits,filed .status.resize
will not be changed by api-server and kubelet
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.
if err != nil || len(oldTemp.Spec.Containers) <= idx { | ||
return fmt.Errorf("invalid container index: %s", op.Path) | ||
} | ||
quantity, err := resource.ParseQuantity(op.Value.(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.
how about the following patch
{ "op": "remove", "path": "/spec/containers/0/resources/limits/cpu" }
it is possible to unset the container resource for one of the container in the pod of burstable qos class
d0db898
to
fe87fa5
Compare
Signed-off-by: LavenderQAQ <lavenderqaq.cs@gmail.com>
Signed-off-by: LavenderQAQ <lavenderqaq.cs@gmail.com>
…tations Signed-off-by: LavenderQAQ <lavenderqaq.cs@gmail.com>
Signed-off-by: LavenderQAQ <lavenderqaq.cs@gmail.com>
Signed-off-by: Abner-1 <yuanyuxing.yyx@alibaba-inc.com>
fe87fa5
to
e5f2c6d
Compare
Signed-off-by: Abner-1 <yuanyuxing.yyx@alibaba-inc.com>
e5f2c6d
to
ee835ac
Compare
Ⅰ. Describe what this PR does
Enhanced the in-place update module to enable kruise's workload to modify resources without restarting the pod.
Ⅱ. Does this pull request fix one issue?
Fixes #1212
Ⅲ. Describe how to verify it
Need to kubernetes v1.27 version, and open feature gate
InPlacePodVerticalScaling
. Here is my kind configuration:Build a cloneset (or other workload that includes in-place updates) and set updateStrategy to InPlaceIfPossible. Here's an example:
Change the workload's resources, wait a while, and you'll find that the pod's resources will change, and the pod won't restart.
Ⅳ. Special notes for reviews
The control of Status for vertical scaling requires a higher version of the k8s api, which makes this pr need to wait for kruise version upgrade. It cannot be merged at this time because it is not yet complete.