Skip to content

Commit 32bc885

Browse files
committed
Add details about upgrade/downgrades, feature gate.
1 parent b01f5d8 commit 32bc885

File tree

2 files changed

+40
-50
lines changed

2 files changed

+40
-50
lines changed

keps/sig-autoscaling/4951-configurable-hpa-tolerance/README.md

Lines changed: 34 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ tags, and then generate with `hack/update-toc.sh`.
5858
- [Goals](#goals)
5959
- [Non-Goals](#non-goals)
6060
- [Proposal](#proposal)
61-
- [User Stories (Optional)](#user-stories-optional)
62-
- [Story 1](#story-1)
63-
- [Story 2](#story-2)
64-
- [Notes/Constraints/Caveats (Optional)](#notesconstraintscaveats-optional)
6561
- [Risks and Mitigations](#risks-and-mitigations)
6662
- [Design Details](#design-details)
6763
- [Test Plan](#test-plan)
@@ -216,38 +212,47 @@ type HPAScalingRules struct {
216212
// tolerance is the tolerance on the ratio between the current and desired
217213
// metric value under which no updates are made to the desired number of
218214
// replicas.
219-
// +optional
215+
// +optional
220216
Tolerance *resource.Quantity
221217

222218
// Existing fields.
223-
StabilizationWindowSeconds *int32
224-
SelectPolicy *ScalingPolicySelect
225-
Policies []HPAScalingPolicy
219+
StabilizationWindowSeconds *int32
220+
SelectPolicy *ScalingPolicySelect
221+
Policies []HPAScalingPolicy
226222
}
227223
```
228224

229-
This new tolerance will be taken into account in [replica_calculator.go][]. The
230-
existing logic is:
225+
This new tolerance will be taken into account in the autoscaling controller
226+
[replica_calculator.go][]. The update to the logic is:
231227

232228
```golang
233229
if math.Abs(1.0-usageRatio) <= c.tolerance { /* ... */ }
234230
```
235231

236232
It will be replaced by:
237233

238-
```golang
239-
// Down and Up scaling tolerances default to c.tolerance if unset.
240-
downTolerance, upTolerance := c.tolerance, c.tolerance
241-
if scaleDown.tolerance != nil {
242-
downTolerance = scaleDown.tolerance.AsApproximateFloat64()
243-
}
244-
if scaleUp.tolerance != nil {
245-
upTolerance = scaleUp.tolerance.AsApproximateFloat64()
246-
}
247-
248-
if (1.0-downTolerance) < usageRatio && usageRatio < (1.0+upTolerance) { /* ... */ }
234+
```diff
235+
- if math.Abs(1.0-usageRatio) <= c.tolerance { /* ... */ }
236+
+ // Down and Up scaling tolerances default to c.tolerance if unset.
237+
+ downTolerance, upTolerance := c.tolerance, c.tolerance
238+
+ if scaleDown.tolerance != nil {
239+
+ downTolerance = scaleDown.tolerance.AsApproximateFloat64()
240+
+ }
241+
+ if scaleUp.tolerance != nil {
242+
+ upTolerance = scaleUp.tolerance.AsApproximateFloat64()
243+
+ }
244+
+
245+
+ if (1.0-downTolerance) <= usageRatio && usageRatio <= (1.0+upTolerance) { /* ... */ }
249246
```
250247

248+
Since the added field is optional and has a default value compatible with the
249+
current autoscaling behavior, this feature can be added to the current API
250+
version `pkg/apis/autoscaling/v2`.
251+
252+
The feature presented in this KEP only allows to tune an existing parameter, and
253+
as such doesn't require any new HPA Events or modify any Status. A new error is
254+
emitted if a `tolerance` field is set to a negative value.
255+
251256
[replica_calculator.go]: https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/podautoscaler/replica_calculator.go
252257

253258
### Test Plan
@@ -396,32 +401,18 @@ in back-to-back releases.
396401

397402
### Upgrade / Downgrade Strategy
398403

399-
<!--
400-
If applicable, how will the component be upgraded and downgraded? Make sure
401-
this is in the test plan.
404+
Upgrades present no particular issue: the new field won't be set and the HPA
405+
will behave like it does today. Users can use the new feature by setting the
406+
new `tolerance` field (provided the Feature Gate is enabled).
402407

403-
Consider the following in developing an upgrade/downgrade strategy for this
404-
enhancement:
405-
- What changes (in invocations, configurations, API use, etc.) is an existing
406-
cluster required to make on upgrade, in order to maintain previous behavior?
407-
- What changes (in invocations, configurations, API use, etc.) is an existing
408-
cluster required to make on upgrade, in order to make use of the enhancement?
409-
-->
408+
On downgrades to a version that does not support this functionality, an HPA will
409+
ignore any configured `tolerance` field, and use the default (as specified by
410+
`--horizontal-pod-autoscaler-tolerance`).
410411

411412
### Version Skew Strategy
412413

413-
<!--
414-
If applicable, how will the component handle version skew with other
415-
components? What are the guarantees? Make sure this is in the test plan.
416-
417-
Consider the following in developing a version skew strategy for this
418-
enhancement:
419-
- Does this enhancement involve coordinating behavior in the control plane and nodes?
420-
- How does an n-3 kubelet or kube-proxy without this feature available behave when this feature is used?
421-
- How does an n-1 kube-controller-manager or kube-scheduler without this feature available behave when this feature is used?
422-
- Will any other components on the node change? For example, changes to CSI,
423-
CRI or CNI may require updating that component before the kubelet.
424-
-->
414+
This feature is entirely implemented in the horizontal autoscaling controller
415+
and does not introduce any changes that would be impacted by version skews.
425416

426417
## Production Readiness Review Questionnaire
427418

keps/sig-autoscaling/4951-configurable-hpa-tolerance/kep.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ stage: alpha
2424
# The most recent milestone for which work toward delivery of this KEP has been
2525
# done. This can be the current (upcoming) milestone, if it is being actively
2626
# worked on.
27-
latest-milestone: "v1.19"
27+
#latest-milestone: "v1.19"
2828

2929
# The milestone at which this feature was, or is targeted to be, at each stage.
3030
milestone:
@@ -34,12 +34,11 @@ milestone:
3434

3535
# The following PRR answers are required at alpha release
3636
# List the feature gate name and the components for which it must be enabled
37-
#feature-gates:
38-
# - name: MyFeature
39-
# components:
40-
# - kube-apiserver
41-
# - kube-controller-manager
42-
#disable-supported: true
37+
feature-gates:
38+
- name: HPAConfigurableTolerance
39+
components:
40+
- kube-apiserver
41+
disable-supported: true
4342

4443
# The following PRR answers are required at beta release
4544
#metrics:

0 commit comments

Comments
 (0)