Skip to content

Conversation

@maxcao13
Copy link
Member

This just addes the UpdateModeInPlaceOrRecreate mode to the types so we can use it.

What type of PR is this?

/kind api-change

What this PR does / why we need it:

We need the new API to allow users to specify the new InPlaceOrRecreate mode as part of AEP-4016.

Which issue(s) this PR fixes:

This PR is part of the larger feature PR in #7673

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

[AEP-4016](https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler/enhancements/4016-in-place-updates-support)

@k8s-ci-robot k8s-ci-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 14, 2025
@k8s-ci-robot k8s-ci-robot added area/vertical-pod-autoscaler size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 14, 2025
@maxcao13 maxcao13 force-pushed the in-place-updates-apichanges branch from 6528d05 to 7040e26 Compare March 14, 2025 22:35
This adds the UpdateModeInPlaceOrRecreate mode to the types so we
can use it.

Signed-off-by: Max Cao <[email protected]>
@maxcao13 maxcao13 force-pushed the in-place-updates-apichanges branch from 7040e26 to 7b462b1 Compare March 15, 2025 02:17
@adrianmoisey
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 15, 2025
@omerap12
Copy link
Member

If we modify the CRD, shouldn’t we also update its version?

@maxcao13
Copy link
Member Author

maxcao13 commented Mar 17, 2025

If we modify the CRD, shouldn’t we also update its version?

I'm not sure but it's probably a good idea since this is a big enhancement? I'd defer to an approver for this one.

@adrianmoisey
Copy link
Member

If we modify the CRD, shouldn’t we also update its version?

I'm not sure but it's probably a good idea since this is a big enhancement? I'd defer to an approver for this one.

I'm not 100% sure, we need to get confirmation here, but since this is a backwards compatible change to the API, we don't need to bump it.

@omerap12
Copy link
Member

If we modify the CRD, shouldn’t we also update its version?

I'm not sure but it's probably a good idea since this is a big enhancement? I'd defer to an approver for this one.

I'm not 100% sure, we need to get confirmation here, but since this is a backwards compatible change to the API, we don't need to bump it.

cc @voelzmo @raywainman

@adrianmoisey
Copy link
Member

There seems to be some guidelines here:
https://github.com/kubernetes/community/blob/19094aa6e60eb4a481650c4cbdb94badd9919b5b/contributors/devel/sig-architecture/api_changes.md#on-compatibility

@raywainman
Copy link
Member

Nice find on the guidelines @adrianmoisey. My understanding is that this change would fall under these new enum value guidelines.

From my interpretation, we are following the required steps here by guarding usage via a feature flag.

My understanding here is that we do not need a new API version to introduce this change.

Would love at least one more person to confirm though :)

cc @kwiesmueller

@maxcao13
Copy link
Member Author

maxcao13 commented Mar 17, 2025

I'll link that part you mentioned for convenience: https://github.com/kubernetes/community/blob/19094aa6e60eb4a481650c4cbdb94badd9919b5b/contributors/devel/sig-architecture/api_changes.md#new-enum-value-in-existing-field

Going through the steps to ensure compatibility:

  1. Add a feature gate to the API server to control enablement of the new enum value (and associated function):

Yes, we've done that in the other PR.

  1. Update the documentation on the API type:

I can update the description a bit better to match the example:

type Frobber struct {
  // restartPolicy may be set to "Always" or "Never" (or "OnTuesday" if the alpha "FrobberRestartPolicyOnTuesday" feature is enabled).
  // Additional policies may be defined in the future.
  // Unrecognized policies should be treated as "Never".
  RestartPolicy string `json:"policy"
}

Never mind, it seems already seems to fine to me I think, unless people has other thoughts.

  1. When validating the object, determine whether the new enum value should be allowed. This prevents new usage of the new value when the feature is disabled, while ensuring existing data is preserved. Ensuring existing data is preserved is needed so that when the feature is enabled by default in a future version n and data is unconditionally allowed to be persisted in the field, an n-1 API server (with the feature still disabled by default) will not choke on validation. The recommended place to do this is in the REST storage strategy's Validate/ValidateUpdate methods:

We don't use the REST storage strategy in VPA (to my knowledge), but we validate VPA during creation using the VPA webhook. I've already taken care of this in the big PR #7673, so that will come in later. (Prevents creation of the new field, but doesn't error if already persisted or updated: https://github.com/kubernetes/autoscaler/pull/7673/files#diff-ad66c76a76541b7991631925641b989fc402901440d8e0dcbc3591009eef52b9R126. I just need to add an extra isCreate to that if statement, and hopefully I don't forget :p)

Question is if and how we can test different VPA versions, though. Maybe a followup PR is needed?

  1. In validation, validate the enum value based on the passed-in options:

Same as above, done in the big PR.

  1. After at least one release, the feature can be promoted to beta or GA and enabled by default.

We'll take care of that later, and it's already documented in the AEP thanks to Adrian.

So I think we are good here not to update the CRD (coming from the author, so another confirmation would be awesome as Ray said), but please let me know if I missed anything.

Copy link
Member

@kwiesmueller kwiesmueller left a comment

Choose a reason for hiding this comment

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

Sounds good to me.
I wonder if we should make this clear on the field somehow (not sure if kubebuilder supports annotating a single enum option.
But at least in the doc we should say that it might not be supported yet or is feature guarded.

The guidelines are for kube-api, but we can translate them.
We should probably test that an older version of VPA doesn't panic/fail if it sees the new enum value. If it did we should fix that before we check-in this change (and even then it's a bit tricky).

Otherwise in the actual implementation as you discussed above we should comply with the validation guide. So a resource that has the field set, despite the feature being disabled, should be allowed to keep it iirc. while only new uses should be blocked if the feature is off.

@raywainman
Copy link
Member

We should probably test that an older version of VPA doesn't panic/fail if it sees the new enum value. If it did we should fix that before we check-in this change (and even then it's a bit tricky).

That was my one worry as well, I quickly scanned the code and I believe we would simply treat this the same as Auto but it is worth validating at some point (I think we can totally do this during the "alpha" phase of this).

@raywainman
Copy link
Member

/lgtm

/approval

@raywainman
Copy link
Member

/hold

In case anyone else wants to take a look

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 17, 2025
@raywainman
Copy link
Member

@maxcao13 maybe we let this one soak for another day or so and then remove the hold?

@maxcao13
Copy link
Member Author

Sure, I'm good with that. Thanks!

@raywainman
Copy link
Member

/unhold - this has soaked for long enough

@raywainman
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: maxcao13, raywainman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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 Mar 21, 2025
@raywainman
Copy link
Member

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 21, 2025
@k8s-ci-robot k8s-ci-robot merged commit 835e647 into kubernetes:in-place-updates Mar 21, 2025
7 checks passed
@maxcao13 maxcao13 deleted the in-place-updates-apichanges branch March 21, 2025 19:55
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/vertical-pod-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants