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

Make autoscaler leader aware #6814

Merged
merged 1 commit into from
Mar 14, 2023

Conversation

pierDipi
Copy link
Member

@pierDipi pierDipi commented Mar 13, 2023

Fixes #6732

The autoscaler runs in every controller replica [1], it tries
to scale down on every replica after the given refresh period,
and sometimes the 2 replicas don't agree on which value to use
for the new replicas since the state is lister/cache based,
leading to a too fast scale up or down behavior or sometime
not converging.
(also because of #6733)

Implementations should be using knative/pkg#2675
for enabling leader-aware autoscaler. (PR knative/pkg#2688)

[1]

func (a *autoscaler) Start(ctx context.Context) {
attemptScaleDown := false
pending := int32(0)
for {
select {
case <-ctx.Done():
return
case <-time.After(a.refreshPeriod):
attemptScaleDown = true
case pending = <-a.trigger:
attemptScaleDown = false
}
// Retry a few times, just so that we don't have to wait for the next beat when
// a transient error occurs
a.syncAutoscale(ctx, attemptScaleDown, pending)
pending = int32(0)
}
}

@knative-prow knative-prow bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 13, 2023
@pierDipi pierDipi changed the title Make autoscaler leader aware [WIP] Make autoscaler leader aware Mar 13, 2023
@knative-prow knative-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 13, 2023
The autoscaler runs in every controller replica [1], it tries
to scale down on every replica after the given refresh period,
and sometimes the 2 replicas don't agree on which value to use
for the new replicas since the state is lister/cache based,
leading to a too fast scale up or down behavior or sometime
not converging.
(also because of knative#6733)

[1]
https://github.com/knative/eventing/blob/1092472f440586099d6a5cbf1d3234bb36431af4/pkg/scheduler/statefulset/autoscaler.go#L85-L103

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
@pierDipi pierDipi force-pushed the autoscaler-leader-aware branch from 0f0260d to 0e207a0 Compare March 13, 2023 12:38
@codecov
Copy link

codecov bot commented Mar 13, 2023

Codecov Report

Patch coverage: 84.61% and no project coverage change.

Comparison is base (eabc874) 80.45% compared to head (0e207a0) 80.46%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6814   +/-   ##
=======================================
  Coverage   80.45%   80.46%           
=======================================
  Files         236      236           
  Lines       12213    12237   +24     
=======================================
+ Hits         9826     9846   +20     
- Misses       1896     1899    +3     
- Partials      491      492    +1     
Impacted Files Coverage Δ
pkg/scheduler/statefulset/autoscaler.go 77.65% <81.25%> (+0.21%) ⬆️
pkg/scheduler/statefulset/scheduler.go 77.27% <90.00%> (+0.21%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@pierDipi pierDipi changed the title [WIP] Make autoscaler leader aware Make autoscaler leader aware Mar 13, 2023
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 13, 2023
@pierDipi
Copy link
Member Author

/cc @matzew

@knative-prow knative-prow bot requested a review from matzew March 13, 2023 12:55
Copy link
Member

@matzew matzew left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Mar 14, 2023
@knative-prow
Copy link

knative-prow bot commented Mar 14, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: matzew, pierDipi

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 knative-prow bot merged commit 62eb85e into knative:main Mar 14, 2023
vishal-chdhry pushed a commit to vishal-chdhry/eventing that referenced this pull request Mar 14, 2023
Fixes knative#6732 

The autoscaler runs in every controller replica [1], it tries
to scale down on every replica after the given refresh period,
and sometimes the 2 replicas don't agree on which value to use
for the new replicas since the state is lister/cache based,
leading to a too fast scale up or down behavior or sometime
not converging.
(also because of knative#6733)

Implementations should be using
knative/pkg#2675
for enabling leader-aware autoscaler. (PR
knative/pkg#2688)

[1]

https://github.com/knative/eventing/blob/1092472f440586099d6a5cbf1d3234bb36431af4/pkg/scheduler/statefulset/autoscaler.go#L85-L103

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
vishal-chdhry pushed a commit to vishal-chdhry/eventing that referenced this pull request Apr 25, 2023
Fixes knative#6732 

The autoscaler runs in every controller replica [1], it tries
to scale down on every replica after the given refresh period,
and sometimes the 2 replicas don't agree on which value to use
for the new replicas since the state is lister/cache based,
leading to a too fast scale up or down behavior or sometime
not converging.
(also because of knative#6733)

Implementations should be using
knative/pkg#2675
for enabling leader-aware autoscaler. (PR
knative/pkg#2688)

[1]

https://github.com/knative/eventing/blob/1092472f440586099d6a5cbf1d3234bb36431af4/pkg/scheduler/statefulset/autoscaler.go#L85-L103

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
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. lgtm Indicates that a PR is ready to be merged. 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.

Scheduler autoscaler is not leader aware
2 participants