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

Add Vertical Pod Autoscaler to autoscaling/v2beta1 #63797

Merged
merged 3 commits into from Jun 7, 2018

Conversation

kgrygiel
Copy link

@kgrygiel kgrygiel commented May 14, 2018

What this PR does / why we need it:
Adds Vertical Pod Autoscaler (https://github.com/kubernetes/community/blob/master/contributors/design-proposals/autoscaling/vertical-pod-autoscaler.md) to the autoscaling API (which currently has the Horizontal Pod Autoscaler).
This is needed for the Vertical Pod Autoscaler beta.

Special notes for your reviewer:

/cc @thockin @mwielgus @DirectXMan12

FYI. changes that add pkg/registry/autoscaling/verticalpodautoscaler/... will follow.

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label May 14, 2018
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 14, 2018
@k8s-github-robot k8s-github-robot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label May 14, 2018
@kgrygiel kgrygiel force-pushed the master branch 3 times, most recently from adf2996 to b396dd5 Compare May 15, 2018 22:12
@thockin
Copy link
Member

thockin commented May 16, 2018

Is this ready for review?

@kgrygiel kgrygiel force-pushed the master branch 2 times, most recently from 314992a to fc4a756 Compare May 16, 2018 14:59
@mwielgus
Copy link
Contributor

@thockin Yes, the api is ready for review.

@mwielgus mwielgus added the sig/autoscaling Categorizes an issue or PR as relevant to SIG Autoscaling. label May 16, 2018
@mwielgus
Copy link
Contributor

/lgtm

from the sig-autoscaling point of view.

@DirectXMan12 - last chance to veto :).

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 24, 2018
@DirectXMan12
Copy link
Contributor

hold on, I had some comments that never got sent
/hold

@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 May 25, 2018

var (
// Configured indicates whether the VPA recommender was able to load a valid VPA spec.
Configured VerticalPodAutoscalerConditionType = "Configured"
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this if we have validation instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Right. Can be removed.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

// UpdateModeAuto means that autoscaler assigns resources on pod creation
// and additionally can update them during the lifetime of the pod,
// including evicting / rescheduling the pod.
UpdateModeAuto UpdateMode = "Auto"
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be "AutoRecreate", so that we can add "AutoInPlace" when we have in-place updates, and not be confusing (recreate is still valuable for things that need to do some resource-based config on creation, like environments that pre-set a heap size limit).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok.

Copy link
Author

Choose a reason for hiding this comment

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

Good point. I suggest we actually may want both. I think many users would want to configure the best (least intrusive) actuation method available. Once we have in-place updates, "auto" will automatically get promoted to in-place without rewriting configs. WDYT?

Name string
// Whether autoscaler is enabled for the container. Defaults to "On".
// +optional
Mode ContainerScalingMode
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want to just make this enabled and be a boolean?

Copy link
Contributor

Choose a reason for hiding this comment

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

There might be some other options added in the future. I would stay with enum.

Copy link
Member

Choose a reason for hiding this comment

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

Can we name the options in a less "this should be a bool" way ?

Copy link
Author

Choose a reason for hiding this comment

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

I can imagine potentially more interesting policies in future, if users need it, e.g. "OnlyScaleUp". However I can't think of better names for the current options..

Copy link
Member

Choose a reason for hiding this comment

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

"Auto" and "Off" ?

}

// PodResourcePolicy controls how autoscaler computes the recommended resources
// for containers belonging to the pod.
Copy link
Contributor

Choose a reason for hiding this comment

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

// PodResourcePolicy controls how autoscaler computes the recommended resources
// or containers belonging to the pod.  There must either be an entry for every named pod,
// or a wildcard entry.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

)

// RecommendedPodResources is the recommendation of resources computed by
// autoscaler.
Copy link
Contributor

Choose a reason for hiding this comment

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

... It contains a recommendation for each container in the pod

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@DirectXMan12
Copy link
Contributor

(just some minor nits)

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 28, 2018
Copy link
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

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

I only reviewed the API parts. A few relatively minor comments overall.

type VerticalPodAutoscalerStatus struct {
// The time when the status was last refreshed.
// +optional
LastUpdateTime metav1.Time
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain the need for this? It's not present in any other APIs

Copy link
Member

Choose a reason for hiding this comment

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

agree... heartbeat-style fields tend to cause scale issues (write traffic persists even in steady state)

Copy link
Author

Choose a reason for hiding this comment

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

The purpose was to let the user know about the freshness of the recommendation. But I understand your concern and I'm ok with deleting it.


// VerticalPodAutoscalerCondition describes the state of
// a VerticalPodAutoscaler at a certain point.
type VerticalPodAutoscalerCondition struct {
Copy link
Member

Choose a reason for hiding this comment

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

I think we could consider some common definition of Condition. Several APIs define their own FooCondition struct but they are all almost identical. The strong typing of the string doesn't protect against illegal values (Go does not have enums) anyway.

@kubernetes/api-reviewers
@bgrant0607 @smarterclayton

Copy link
Author

Choose a reason for hiding this comment

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

ACK. However in this step I would rather keep vpa consistent with hpa and perhaps consider having both (and others) changed together in a larger rewrite?

Copy link
Member

Choose a reason for hiding this comment

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

ACK

)

// PodUpdatePolicy describes the rules on how changes are applied to the pods.
type PodUpdatePolicy struct {
Copy link
Member

Choose a reason for hiding this comment

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

This is a little invasive, but Can we organize these files in Go-introduction order? I find it makes reviews much easier.

E.g.


type VPA {
    Spec VPASpec
    Status VPAStatus
}

type VPASpec {
    Foo FooType
    Bar BarType
}

type FooType {
   Whatever EnumString
}

Type EnumString

Type BarType

type VPAStatus {
    Qux QuxType
}

Copy link
Author

Choose a reason for hiding this comment

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

Done.

Name string
// Whether autoscaler is enabled for the container. Defaults to "On".
// +optional
Mode ContainerScalingMode
Copy link
Member

Choose a reason for hiding this comment

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

Can we name the options in a less "this should be a bool" way ?

@kgrygiel kgrygiel force-pushed the master branch 2 times, most recently from e94d35d to 39c25a1 Compare May 30, 2018 14:54

// Describes the rules on how changes are applied to the pods.
// +optional
UpdatePolicy PodUpdatePolicy
Copy link
Member

Choose a reason for hiding this comment

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

If this is optional, what is the default? Document.

Copy link
Author

Choose a reason for hiding this comment

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

Done.


// Controls how the autoscaler computes recommended resources.
// +optional
ResourcePolicy PodResourcePolicy
Copy link
Member

Choose a reason for hiding this comment

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

Document default behavior.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

type PodUpdatePolicy struct {
// Controls when autoscaler applies changes to the pod resoures.
// +optional
UpdateMode UpdateMode
Copy link
Member

Choose a reason for hiding this comment

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

Why is this optional, when the struct itself is optional above? Put another way, is there a plausible future where the user specifies VP.spec.updatePolicy and provides a struct that does not include mode?

Copy link
Member

Choose a reason for hiding this comment

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

Also, all truly optional fields should be nil-able, (pointers or slices or maps)

Copy link
Author

Choose a reason for hiding this comment

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

PodUpdatePolicy may in future consist of multiple optional settings. It might be possible to specify PodUpdatePolicy with some other settings but leaving the mode unset (i.e. use the default).

Reg. nil-able fields: I've changed all optional fields to pointers, although I excluded "enum" string fields, because they support a natural empty value (an empty string) and I think this approach is widely used across other APIs elsewhere. WDYT?


// Specification of the behavior of the autoscaler.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status.
// +optional
Copy link
Member

Choose a reason for hiding this comment

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

is spec really optional? What is the behavior if it is not provided? Document.

Copy link
Author

Choose a reason for hiding this comment

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

Removed optional.
Not sure why other APIs make it optional.

// named container and optionally a single wildcard entry with Name = "*", which
// handles all containers that don't have individual policies.
type PodResourcePolicy struct {
// Per-container resource policies.
Copy link
Member

Choose a reason for hiding this comment

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

default behavior if omitted?

Copy link
Author

Choose a reason for hiding this comment

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

Added a comment to ResourcePolicy PodResourcePolicy. In general this policy allows to provide constraints on how recommendations are computed for each container. If some container is not mentioned, there are no constraints on it.


var (
// RecommendationProvided indicates whether the VPA recommender was able to calculate a recommendation.
RecommendationProvided VerticalPodAutoscalerConditionType = "RecommendationProvided"
Copy link
Member

Choose a reason for hiding this comment

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

Shorten to "Recommended" ? Maybe..

Copy link
Author

Choose a reason for hiding this comment

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

Not sure about this one.. I would prefer it to be as self-descriptive as possible.

Copy link
Member

Choose a reason for hiding this comment

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

ACK


// VerticalPodAutoscalerCondition describes the state of
// a VerticalPodAutoscaler at a certain point.
type VerticalPodAutoscalerCondition struct {
Copy link
Member

Choose a reason for hiding this comment

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

ACK

func validateVerticalPodAutoscalerSpec(spec *autoscaling.VerticalPodAutoscalerSpec, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if spec != nil {
if spec.Selector != nil {
Copy link
Member

Choose a reason for hiding this comment

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

usually I see this flipped. Required test then valid test. Minor.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

type VerticalPodAutoscalerSpec struct {
// A label query that determines the set of pods controlled by the Autoscaler.
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
Selector *metav1.LabelSelector `json:"selector,omitempty" protobuf:"bytes,1,opt,name=selector"`
Copy link
Member

Choose a reason for hiding this comment

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

Is this optional or not? Doesn't say +optional, but is a pointer and proto says 'opt' ?

Copy link
Author

Choose a reason for hiding this comment

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

Fixed the annotation. Technically a nil selector is legal (matches nothing), however we disallowed it during validation. As far as I could see this approach was used elsewhere.

type PodResourcePolicy struct {
// Per-container resource policies.
// +optional
ContainerPolicies []ContainerResourcePolicy `json:"containerPolicies,omitempty" protobuf:"bytes,1,rep,name=containerPolicies"`
Copy link
Member

Choose a reason for hiding this comment

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

I think we need patchStrategy and patchMergeKey on all lists.

@pwittrock

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 6, 2018
@mwielgus
Copy link
Contributor

mwielgus commented Jun 6, 2018

Adding approved-for-milestone as a sig-lead.

@mwielgus mwielgus added status/approved-for-milestone priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. kind/feature Categorizes issue or PR as related to a new feature. labels Jun 6, 2018
@k8s-github-robot
Copy link

[MILESTONENOTIFIER] Milestone Pull Request: Up-to-date for process

@kgrygiel @mwielgus @thockin

Pull Request Labels
  • sig/autoscaling: Pull Request will be escalated to these SIGs if needed.
  • priority/critical-urgent: Never automatically move pull request out of a release milestone; continually escalate to contributor and SIG through all available channels.
  • kind/feature: New functionality.
Help

@mwielgus
Copy link
Contributor

mwielgus commented Jun 6, 2018

/retest

@jberkus
Copy link

jberkus commented Jun 6, 2018

/hold

Taking discussion to Slack, because I'm concerned about the state of this PR.

@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 Jun 6, 2018
@jberkus
Copy link

jberkus commented Jun 6, 2018

If @DirectXMan12 's objections were resolved on slack or elsewhere, please let me know in a comment and remove the hold. Thanks!

Also, the release team needs to know: (a) what is the risk associated with this patch? (b) are there docs for this?

@mwielgus
Copy link
Contributor

mwielgus commented Jun 7, 2018

@jberkus @DirectXMan12 is on vacation, however his objections seem to be resolved. @DirectXMan12 was one of the reviewer of the original proposal for VPA kubernetes/community#338.

The risk associated with this PR is minimal. It is the api that is handled by an opt-in, independent component. Documentation for the feature is provided currently here:

https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler

We will expand the main K8S doc soon.

@jberkus
Copy link

jberkus commented Jun 7, 2018

/remove-hold

Removing hold per discussion with SIG.

@jberkus
Copy link

jberkus commented Jun 7, 2018

sigh.

/hold cancel

@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 Jun 7, 2018
@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 63c90bb into kubernetes:master Jun 7, 2018
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Jun 7, 2018
k8s-github-robot pushed a commit that referenced this pull request Jun 7, 2018
Automatic merge from submit-queue (batch tested with PRs 64836, 64890). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Revert: Add Vertical Pod Autoscaler to autoscaling/v2beta1

Reverts #63797 per [discussion](https://kubernetes.slack.com/archives/C09R1LV8S/p1528400528000615) with @jberkus and @mwielgus

The scope of the follow-ups required in #64286 was not well understood when the API PR was merged, and we are now past code freeze for 1.11

This can be reopened against 1.12

```release-note
NONE
```
k8s-publishing-bot added a commit to kubernetes/api that referenced this pull request Jun 8, 2018
Automatic merge from submit-queue (batch tested with PRs 64836, 64890). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Revert: Add Vertical Pod Autoscaler to autoscaling/v2beta1

Reverts kubernetes/kubernetes#63797 per [discussion](https://kubernetes.slack.com/archives/C09R1LV8S/p1528400528000615) with @jberkus and @mwielgus

The scope of the follow-ups required in kubernetes/kubernetes#64286 was not well understood when the API PR was merged, and we are now past code freeze for 1.11

This can be reopened against 1.12

```release-note
NONE
```

Kubernetes-commit: 169df7434155cbbc22f1532cba8e0a9588e29ad8
k8s-publishing-bot added a commit to kubernetes/client-go that referenced this pull request Jun 8, 2018
Automatic merge from submit-queue (batch tested with PRs 64836, 64890). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Revert: Add Vertical Pod Autoscaler to autoscaling/v2beta1

Reverts kubernetes/kubernetes#63797 per [discussion](https://kubernetes.slack.com/archives/C09R1LV8S/p1528400528000615) with @jberkus and @mwielgus

The scope of the follow-ups required in kubernetes/kubernetes#64286 was not well understood when the API PR was merged, and we are now past code freeze for 1.11

This can be reopened against 1.12

```release-note
NONE
```

Kubernetes-commit: 169df7434155cbbc22f1532cba8e0a9588e29ad8
kgrygiel pushed a commit to kgrygiel/autoscaler that referenced this pull request Jun 14, 2018
kgrygiel pushed a commit to kgrygiel/autoscaler that referenced this pull request Jun 14, 2018
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. 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 kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. release-note-none Denotes a PR that doesn't merit a release note. sig/autoscaling Categorizes an issue or PR as relevant to SIG Autoscaling. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants