Skip to content

Commit

Permalink
fix scaling bug (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkarlsen authored Feb 2, 2021
1 parent 3948dbe commit 2067ceb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion controllers/githubactionrunner_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func shouldScaleUp(podRunnerPairs podRunnerPairList, instance *garov1alpha1.Gith
}

func shouldScaleDown(podRunnerPairs podRunnerPairList, instance *garov1alpha1.GithubActionRunner) bool {
return podRunnerPairs.numRunners() > instance.Spec.MaxRunners || ((!podRunnerPairs.allBusy()) && podRunnerPairs.numRunners() > instance.Spec.MinRunners)
return podRunnerPairs.numRunners() > instance.Spec.MaxRunners || (podRunnerPairs.numIdle() > 1 && (podRunnerPairs.numRunners() > instance.Spec.MinRunners))
}

func (r *GithubActionRunnerReconciler) manageOutcome(ctx context.Context, instance *garov1alpha1.GithubActionRunner, issue error) (reconcile.Result, error) {
Expand Down
4 changes: 4 additions & 0 deletions controllers/podrunner_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ func (r podRunnerPairList) inSync() bool {
return r.numPods() == r.numRunners()
}

func (r podRunnerPairList) numIdle() int {
return r.numRunners() - r.numBusy()
}

func (r podRunnerPairList) getIdles(sortOrder v1alpha1.SortOrder) []podRunnerPair {
idles := funk.Filter(r.pairs, func(pair podRunnerPair) bool {
return !(pair.runner.GetBusy() || util.IsBeingDeleted(&pair.pod))
Expand Down

0 comments on commit 2067ceb

Please sign in to comment.