Repository navigation
Teach Autoscaler about Scale Down Delay - #9565
Conversation
knative-prow-robot
left a comment
There was a problem hiding this comment.
@julz: 0 warnings.
Details
In response to this:
Part of #9092.
Add ScaleDownDelay to DeciderSpec and teach Autoscaler how to respect it. At this point this is still a no-op since we never actually set a non-zero ScaleDownDelay (next PR will change that).
Couple things worth commenting on:
Although a 1-element scale-down window is almost the same as no window at all, it's not quite the same (because if we run Scale twice in the same interval, which can happen on initial scale-up, we'll pick the largest of the two rather than the most recent), therefore use a
zeroDelaywhen delay is zero. This also makes setting non-zero ScaleDownDelay effectively act as a feature flag for the whole feature, which is nice.The max.TimedWindow package has a slightly different API from the
delayerinterface introduced here (Record/Current vs Delay). I think that's fine and good because the concept of delay is part of autoscaler, and doesn't make much sense in the more genericaggregation/maxpackage, therefore Im wrapping here to avoid polluting the generic package with concepts from the specific one. This may be a terrible idea though; if anyone hates it happy to change it :) (this is all private anyway though)./assign @markusthoemmes @vagababov
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.
Codecov Report
@@ Coverage Diff @@
## master #9565 +/- ##
==========================================
+ Coverage 88.72% 88.81% +0.08%
==========================================
Files 213 213
Lines 9387 9397 +10
==========================================
+ Hits 8329 8346 +17
+ Misses 801 794 -7
Partials 257 257
Continue to review full report at Codecov.
|
| ReadyCount() (int, error) | ||
| } | ||
|
|
||
| type delayer interface { |
There was a problem hiding this comment.
probably a comment would help, what and how we delay
| } | ||
|
|
||
| type delayer interface { | ||
| Delay(now time.Time, value int32) int32 |
There was a problem hiding this comment.
| Delay(now time.Time, value int32) int32 | |
| delay(now time.Time, value int32) int32 |
or we expect external impls?
| type zeroDelay struct{} | ||
|
|
||
| func (zeroDelay) Delay(_ time.Time, v int32) int32 { return v } | ||
|
|
||
| // timeWindowDelay delays scale down decisions using a TimeWindow. | ||
| type timeWindowDelay struct { | ||
| window *max.TimeWindow | ||
| } | ||
|
|
||
| func (t timeWindowDelay) Delay(now time.Time, v int32) int32 { | ||
| t.window.Record(now, v) | ||
| return t.window.Current() | ||
| } |
There was a problem hiding this comment.
I think you can just join those and return v if delay=0.
|
pushed a version that drops the interfaces entirely. @vagababov wdyt? |
|
The following is the coverage report on the affected files.
|
vagababov
left a comment
There was a problem hiding this comment.
/lgtm
/hold
Very nice. I'll let Markus look it over too.
At some point we'll need to chop the function into pieces, but obviously not here.
| return nil, errors.New("stats reporter must not be nil") | ||
| } | ||
|
|
||
| delayer := max.NewTimeWindow(tickInterval, tickInterval) |
There was a problem hiding this comment.
Why do we create this default? Couldn't we pass nil down and then key the usage decision off of this being nil or not? Seems like the default is never used anyway.
There was a problem hiding this comment.
yeah good catch - this is an artefact of when I had a different interface for zero rather than the if
| for i := 0; i < 2; i++ { | ||
| pc.readyCount = i | ||
| a := newAutoscaler(testNamespace, testRevision, metrics, pc, deciderSpec, context.Background()) | ||
| a := newAutoscaler(testNamespace, testRevision, metrics, pc, deciderSpec, max.NewTimeWindow(tickInterval, tickInterval), context.Background()) |
There was a problem hiding this comment.
If you go by the suggestion above, passing nil here might be better.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: julz, markusthoemmes The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/unhold |
|
/retest |
|
We need to do something about that test. |
|
The following jobs failed:
Failed non-flaky tests preventing automatic retry of pull-knative-serving-unit-tests: |
|
hm cc @vagababov I think that's a new one? /retest |
|
I'll look at it. |
Part of #9092.
Add ScaleDownDelay to DeciderSpec and teach Autoscaler how to respect it. At this point this is still a no-op since we never actually set a non-zero ScaleDownDelay (next PR will change that).
Couple things worth commenting on:
Although a 1-element scale-down window is almost the same as no window at all, it's not quite the same (because if we run Scale twice in the same interval, which can happen on initial scale-up, we'll pick the largest of the two rather than the most recent), therefore use a
zeroDelaywhen delay is zero. This also makes setting non-zero ScaleDownDelay effectively act as a feature flag for the whole feature, which is nice.The max.TimedWindow package has a slightly different API from the. Dropped the interfaces \o/.delayerinterface introduced here (Record/Current vs Delay). I think that's fine and good because the concept of delay is part of autoscaler, and doesn't make much sense in the more genericaggregation/maxpackage, therefore Im wrapping here to avoid polluting the generic package with concepts from the specific one. This may be a terrible idea though; if anyone hates it happy to change it :) (this is all private anyway though)./assign @markusthoemmes @vagababov