Skip to content

Commit 01e2827

Browse files
tkuchikiclaude
andauthored
docs: clarify that scheduled scaling can exceed spec max processing units (#250)
* chore: regenerate SpannerManualScaling CRD manifest The go-deps bump (#248) updated controller-tools to v0.21.0, and the SpannerManualScalingSpec godoc was revised in #242 after the manifest was last generated, but config/crd/bases was not regenerated. Run 'make manifests' so the checked-in YAML matches the current toolchain and godoc. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * docs: clarify that scheduled scaling can exceed spec max processing units The scheduled scaling section explained that additionalProcessingUnits "bumps up the scaling range", but never stated the key operational fact: while a SpannerAutoscaleSchedule is active, the value is added to both ends of the autoscaling range, so the instance can be scaled beyond spec.scaleConfig.processingUnits.max by that amount. This has caused operators to read PU values above spec max as a controller bug. Spell the behavior out in the README (effective range, exceeding max, the raised lower bound, and reverting when the window ends) and in the AdditionalProcessingUnits godoc so the generated CRD description and docs/crd-reference.md carry the same explanation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent a1ff7bb commit 01e2827

5 files changed

Lines changed: 34 additions & 12 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ spec:
4545
4646
The `cron` field supports extended syntax (`L`, `L-n`, `nW`, `LW`, `DAY#n`, `DAY#L`) in addition to the standard 5-field format, powered by [go-cron](https://github.com/netresearch/go-cron). See the [Extended Syntax documentation](https://pkg.go.dev/github.com/netresearch/go-cron#hdr-Extended_Syntax__Optional_) for details and examples.
4747

48+
> **Note:** While a schedule is active, `additionalProcessingUnits` is added to **both ends** of the autoscaling range: the effective range becomes `[spec.processingUnits.min + additionalProcessingUnits, spec.processingUnits.max + additionalProcessingUnits]` (exposed as `status.desiredMinPUs` / `status.desiredMaxPUs`). This means the instance can be scaled **beyond `spec.processingUnits.max`** — with `max: 1000` and the schedule above, the instance may reach 1,600 PU while the schedule is active. Because the lower bound is raised as well, the instance is scaled up to at least `min + additionalProcessingUnits` even when CPU utilization is low. Once the schedule's window (`duration`) ends, the range reverts to the values in `spec`, and the instance scales back down after the configured scale-down interval.
49+
4850
> **Note:** When multiple schedules are active simultaneously (i.e. their windows overlap), the `additionalProcessingUnits` from all active schedules are **summed** and added to both `desiredMinPUs` and `desiredMaxPUs`. For example, if schedule A adds +1,000 PU and schedule B adds +5,000 PU and both are active at the same time, `desiredMinPUs = spec.processingUnits.min + 6,000`.
4951

5052
### Scale down time restrictions

api/v1beta1/spannerautoscaleschedule_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ type SpannerAutoscaleScheduleSpec struct {
3838
TargetResource string `json:"targetResource"`
3939

4040
// The extra compute capacity which will be added when this schedule is active.
41+
// While active, this value is added to both the minimum and maximum of the target
42+
// SpannerAutoscaler's autoscaling range, so the instance can be scaled beyond
43+
// `spec.scaleConfig.processingUnits.max` by this amount.
4144
AdditionalProcessingUnits int `json:"additionalProcessingUnits"`
4245

4346
// The details of when and for how long this schedule will be active.

config/crd/bases/spanner.mercari.com_spannerautoscaleschedules.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ spec:
5252
SpannerAutoscaleSchedule
5353
properties:
5454
additionalProcessingUnits:
55-
description: The extra compute capacity which will be added when this
56-
schedule is active.
55+
description: |-
56+
The extra compute capacity which will be added when this schedule is active.
57+
While active, this value is added to both the minimum and maximum of the target
58+
SpannerAutoscaler's autoscaling range, so the instance can be scaled beyond
59+
`spec.scaleConfig.processingUnits.max` by this amount.
5760
type: integer
5861
schedule:
5962
description: The details of when and for how long this schedule will

config/crd/bases/spanner.mercari.com_spannermanualscalings.yaml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.20.1
6+
controller-gen.kubebuilder.io/version: v0.21.0
77
name: spannermanualscalings.spanner.mercari.com
88
spec:
99
group: spanner.mercari.com
@@ -64,14 +64,25 @@ spec:
6464
scaledownAllowedTimes / scaledownNotAllowedTimes windows for as long as it
6565
is active.
6666
67-
Pacing is inferred from the presence of the step-size field for the required
68-
direction:
67+
The target may be above or below the current processing units. The
68+
controller picks the direction from the sign of
69+
(ProcessingUnits - CurrentProcessingUnits) and reads only the step-size /
70+
interval fields for that direction. Pacing is inferred from the presence
71+
of the step-size field:
6972
70-
- ScaleupStepSize unset (when target > current) → single-jump scale-up.
71-
- ScaleupStepSize set (when target > current) → stepped ramp; the
72-
cadence comes from ScaleupInterval when set, otherwise from the
73+
- target > current, ScaleupStepSize unset → single-jump scale-up.
74+
- target > current, ScaleupStepSize set → stepped scale-up ramp;
75+
the cadence comes from ScaleupInterval when set, otherwise from the
7376
controller's --scale-up-interval flag default.
74-
- ScaledownStepSize / ScaledownInterval behave symmetrically.
77+
- target < current, ScaledownStepSize unset → single-jump scale-down.
78+
- target < current, ScaledownStepSize set → stepped scale-down ramp;
79+
the cadence comes from ScaledownInterval when set, otherwise from the
80+
controller's --scale-down-interval flag default.
81+
82+
Manual scale-down is accepted by default. Cluster operators who want to
83+
forbid it can run the controller with --reject-manual-scaledown=true; in
84+
that mode an override whose target is below the current PU lands in the
85+
Invalid phase rather than scaling the instance down.
7586
7687
Interval-only specification (e.g. ScaleupInterval set but ScaleupStepSize
7788
unset) has no effect; the validating webhook emits an admission warning to
@@ -106,8 +117,11 @@ spec:
106117
processingUnits:
107118
description: |-
108119
ProcessingUnits is the target value that this override drives toward
109-
while active. Must be a multiple of 100 (for values < 1000) or a
110-
multiple of 1000.
120+
while active. May be above or below the autoscaler's current PU; the
121+
controller derives the scaling direction from the sign of
122+
(ProcessingUnits - CurrentProcessingUnits) and consults the matching
123+
step-size / interval fields below. Must be a multiple of 100 (for
124+
values < 1000) or a multiple of 1000.
111125
minimum: 100
112126
type: integer
113127
scaledownInterval:

docs/crd-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ _Appears in:_
297297
| Field | Description | Default | Validation |
298298
| --- | --- | --- | --- |
299299
| `targetResource` _string_ | The `SpannerAutoscaler` resource name with which this schedule will be registered.<br />Immutable after creation. | | |
300-
| `additionalProcessingUnits` _integer_ | The extra compute capacity which will be added when this schedule is active. | | |
300+
| `additionalProcessingUnits` _integer_ | The extra compute capacity which will be added when this schedule is active.<br />While active, this value is added to both the minimum and maximum of the target<br />SpannerAutoscaler's autoscaling range, so the instance can be scaled beyond<br />`spec.scaleConfig.processingUnits.max` by this amount. | | |
301301
| `schedule` _[Schedule](#schedule)_ | The details of when and for how long this schedule will be active. | | |
302302

303303

0 commit comments

Comments
 (0)