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

feat: allow pod in place update to cowork with mutating admission webhook #7869

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

fantasy-yzj
Copy link

No description provided.

@CLAassistant
Copy link

CLAassistant commented Jul 24, 2024

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the size/M Denotes a PR that changes 30-99 lines. label Jul 24, 2024
@fantasy-yzj fantasy-yzj changed the title support:allow pod in place update to cowork with mutating admission webhook feat:allow pod in place update to cowork with mutating admission webhook Jul 24, 2024
Copy link

codecov bot commented Jul 24, 2024

Codecov Report

Attention: Patch coverage is 43.75000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 63.33%. Comparing base (7d3b6a8) to head (dcd4689).
Report is 2 commits behind head on main.

Files Patch % Lines
pkg/controller/instanceset/in_place_update_util.go 43.75% 6 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7869      +/-   ##
==========================================
- Coverage   63.39%   63.33%   -0.06%     
==========================================
  Files         339      339              
  Lines       41424    41438      +14     
==========================================
- Hits        26259    26245      -14     
- Misses      12834    12870      +36     
+ Partials     2331     2323       -8     
Flag Coverage Δ
unittests 63.33% <43.75%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@weicao weicao changed the title feat:allow pod in place update to cowork with mutating admission webhook feat: allow pod in place update to cowork with mutating admission webhook Jul 25, 2024
@@ -261,7 +261,10 @@ func equalBasicInPlaceFields(old, new *corev1.Pod) bool {

func equalResourcesInPlaceFields(old, new *corev1.Pod) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

old -> current
new -> expected

is better

@fantasy-yzj fantasy-yzj force-pushed the support/improvement-allow-pod-in-place-update-to-cowork-with-mutating-admission-webhook branch from aeca824 to dcd4689 Compare August 12, 2024 02:02
@@ -259,7 +259,10 @@ func equalBasicInPlaceFields(old, new *corev1.Pod) bool {

func equalResourcesInPlaceFields(old, new *corev1.Pod) bool {
if len(old.Spec.Containers) != len(new.Spec.Containers) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can simply remove this if-statement to support the case.

The following for-loop will make sure that all containers in the new pod are present in the old pod and have the same resources, so if a new container is added to the new pod, the function returns false, which causes a pod recreation. But if the old pod contains unknown containers (injected by external webhooks), the function will still return true, which causes an in-place update.

Copy link
Contributor

Choose a reason for hiding this comment

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

great suggestion!

@fantasy-yzj fantasy-yzj force-pushed the support/improvement-allow-pod-in-place-update-to-cowork-with-mutating-admission-webhook branch from dcd4689 to 14c097b Compare September 13, 2024 02:46
@fantasy-yzj fantasy-yzj requested a review from a team as a code owner September 13, 2024 02:46
@github-actions github-actions bot added size/S Denotes a PR that changes 10-29 lines. and removed size/M Denotes a PR that changes 30-99 lines. labels Sep 13, 2024
@@ -258,9 +258,6 @@ func equalBasicInPlaceFields(old, new *corev1.Pod) bool {
}

func equalResourcesInPlaceFields(old, new *corev1.Pod) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func equalResourcesInPlaceFields(old, new *corev1.Pod) bool {
// equalResourcesInPlaceFields checks if the desired values of pod resources are equal to their current actual values. If they are equal, it returns true. Containers in 'old' that are not recognized (they may have been injected by external mutating admission webhooks) will not participate in the comparison.
func equalResourcesInPlaceFields(old, new *corev1.Pod) bool {

@@ -198,6 +198,28 @@ var _ = Describe("instance util test", func() {
policy, err = getPodUpdatePolicy(its, pod5)
Expect(err).Should(BeNil())
Expect(policy).Should(Equal(NoOpsPolicy))

By("build a pod without revision updated, with IgnorePodVerticalScaling disabled")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
By("build a pod without revision updated, with IgnorePodVerticalScaling disabled")
By("simulating a webhook to add an unknown container to the pod, with IgnorePodVerticalScaling disabled, it should use the in-place update policy")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/S Denotes a PR that changes 10-29 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement] Allow Pod in-place update to cowork with mutating admission webhook
4 participants