这是indexloc提供的服务,不要输入任何密码
Skip to content

HPA v2beta2 #12278

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

Merged
merged 6 commits into from
Nov 16, 2021
Merged

HPA v2beta2 #12278

merged 6 commits into from
Nov 16, 2021

Conversation

enoodle
Copy link
Contributor

@enoodle enoodle commented Nov 15, 2021

Update the HPA autoscaling version to v2beta2 to allow setting window and in the future also scale rate

Proposed Changes

  • Using the v2beta2 hpa autoscaler to allow setting stabilization window and in the future will allow defining scalUp/scaleDown policies using the max-scale-up-rate/max-scale-down-rate.
  • If found, Uses the /window annotation for the HPA autoscaler.

Release Note

Generated HPAs are now v2beta2.
Window annotation will be set to HPA stabilization window

@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Nov 15, 2021
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 15, 2021
@knative-prow-robot
Copy link
Contributor

Hi @enoodle. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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/test-infra repository.

@knative-prow-robot knative-prow-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. area/API API objects and controllers area/autoscale labels Nov 15, 2021
Copy link
Contributor

@markusthoemmes markusthoemmes left a comment

Choose a reason for hiding this comment

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

Let's do a liiiiittle more splitting. My goal would be to have no behavioral change in this first PR and focus just on the API changes.

Comment on lines 161 to 164
if annotations[ClassAnnotationKey] == HPA && (annotations[MetricAnnotationKey] == CPU || annotations[MetricAnnotationKey] == Memory) {
return apis.ErrInvalidKeyName(WindowAnnotationKey, apis.CurrentField, fmt.Sprintf("%s for %s %s", HPA,
MetricAnnotationKey, annotations[MetricAnnotationKey]))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's drop this for a subsequent PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

}, {
name: "value too short and invalid class for /window annotation",
annotations: map[string]string{WindowAnnotationKey: "1s", ClassAnnotationKey: HPA, MetricAnnotationKey: CPU},
expectErr: fmt.Sprintf("invalid key name %q: \n%s for %s %s", WindowAnnotationKey, HPA, MetricAnnotationKey, CPU),
Copy link
Contributor

Choose a reason for hiding this comment

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

Split into the other PR please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Comment on lines 91 to 101
if window, hasWindow := pa.Window(); hasWindow {
windowSeconds := int32(window.Seconds())
hpa.Spec.Behavior = &autoscalingv2beta2.HorizontalPodAutoscalerBehavior{
ScaleDown: &autoscalingv2beta2.HPAScalingRules{
StabilizationWindowSeconds: &windowSeconds,
},
ScaleUp: &autoscalingv2beta2.HPAScalingRules{
StabilizationWindowSeconds: &windowSeconds,
},
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The other PR please :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Resource: &autoscalingv2beta2.ResourceMetricSource{
Name: corev1.ResourceMemory,
Target: autoscalingv2beta2.MetricTarget{
Type: "AverageValue",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a constant for AverageValue and Utilization maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@markusthoemmes
Copy link
Contributor

/ok-to-test

@knative-prow-robot knative-prow-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 15, 2021
@codecov
Copy link

codecov bot commented Nov 15, 2021

Codecov Report

Merging #12278 (ba6b557) into main (eb83774) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #12278      +/-   ##
==========================================
+ Coverage   87.25%   87.31%   +0.05%     
==========================================
  Files         195      195              
  Lines        9605     9610       +5     
==========================================
+ Hits         8381     8391      +10     
+ Misses        941      939       -2     
+ Partials      283      280       -3     
Impacted Files Coverage Δ
pkg/reconciler/autoscaling/hpa/controller.go 100.00% <ø> (ø)
pkg/reconciler/autoscaling/hpa/hpa.go 91.17% <100.00%> (ø)
pkg/reconciler/autoscaling/hpa/resources/hpa.go 100.00% <100.00%> (ø)
pkg/autoscaler/statserver/server.go 77.66% <0.00%> (-1.95%) ⬇️
pkg/reconciler/configuration/configuration.go 86.15% <0.00%> (+1.53%) ⬆️
pkg/autoscaler/statforwarder/processor.go 94.44% <0.00%> (+5.55%) ⬆️
pkg/autoscaler/statforwarder/forwarder.go 96.29% <0.00%> (+5.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb83774...ba6b557. Read the comment docs.

Copy link
Contributor

@psschwei psschwei left a comment

Choose a reason for hiding this comment

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

Does the e2e test also need to be updated to v2beta2?

Copy link
Member

@nader-ziada nader-ziada left a comment

Choose a reason for hiding this comment

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

The only thing I see missing is the e2e test Paul mentioned, otherwise the PR changes the version without any behavioural changes and tests are passing, so looking good

Resource: &autoscalingv2beta2.ResourceMetricSource{
Name: corev1.ResourceCPU,
Target: autoscalingv2beta2.MetricTarget{
Type: "Utilization",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should use the same constant as above (throughout this file)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@knative-prow-robot knative-prow-robot added the area/test-and-release It flags unit/e2e/conformance/perf test issues for product features label Nov 15, 2021
@nader-ziada
Copy link
Member

lgtm

Copy link
Contributor

@markusthoemmes markusthoemmes left a comment

Choose a reason for hiding this comment

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

I checked the availability of the API and v2beta1 seems to have been deprecated in 1.19, so this is timely!

Thanks!

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 16, 2021
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: enoodle, markusthoemmes

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 16, 2021
@knative-prow-robot knative-prow-robot merged commit 532231b into knative:main Nov 16, 2021
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/API API objects and controllers area/autoscale area/test-and-release It flags unit/e2e/conformance/perf test issues for product features cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants