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

[Do not merge] alternative approach to clear state when not leader anymore #75

Closed
wants to merge 3 commits into from

Conversation

alpe
Copy link
Contributor

@alpe alpe commented Feb 7, 2024

Based on #70

The autoscaler registers a callback on the elector when to stop scalers when not leader anymore.
This PR also contains changes to the scaler from #74

@@ -71,6 +71,7 @@ func (r *Autoscaler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
}

func (a *Autoscaler) Start() {
a.LeaderElection.AfterOnStoppedLeading(a.Deployments.StopScalers)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cleanup desired scale and downscale when instance is not leader anymore

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would break scale from 0 in the proxy which should still be possible

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this would break the h.Deployments.AtLeastOne(deploy) call in the proxies that are not a leader.

Copy link
Contributor

Choose a reason for hiding this comment

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

nvm it won't break that since it's a different flow. Currently all stop does is to stop the scale down timer.

s.scaleDownStarted = false // mark completed already
desiredScale, currentScale := s.desiredScale, s.currentScale
s.mtx.Unlock()
if desiredScale == -1 || desiredScale == currentScale {
Copy link
Contributor

Choose a reason for hiding this comment

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

s.desiredScale could only be -1 right after initialization right? because there is this if earlier in scaler:

	if current != -1 {
		s.currentScale = current
	}
	if desired != -1 {
		s.desiredScale = desired
	}

asking to improve my understanding, this is not feedback to your code or a request for any changes

Copy link
Contributor

@samos123 samos123 left a comment

Choose a reason for hiding this comment

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

changes make sense overall except stopping all scalers, I think that would break the h.Deployments.AtLeastOne(deploy) call in the proxies that are not a leader.

@samos123
Copy link
Contributor

samos123 commented Feb 7, 2024

will include this in #76

@samos123 samos123 closed this Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants