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

Scale to zero #436

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/v1alpha1/githubactionrunner_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ type GithubActionRunnerSpec struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Repository",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
Repository string `json:"repository,omitempty"`

// Minimum pool-size. Note that you need one runner in order for jobs to be schedulable, else they fail claiming no runners match the selector labels.
// Minimum pool-size.
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Required
// +kubebuilder:default=1
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Minimum Pool Size",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:podCount"}
MinRunners int `json:"minRunners"`

// Maximum pool-size. Must be greater or equal to minRunners
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Required
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Maximum Pool Size",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:podCount"}
MaxRunners int `json:"maxRunners"`
Expand Down
6 changes: 2 additions & 4 deletions config/crd/bases/garo.tietoevry.com_githubactionrunners.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,11 @@ spec:
type: string
maxRunners:
description: Maximum pool-size. Must be greater or equal to minRunners
minimum: 1
minimum: 0
type: integer
minRunners:
default: 1
description: Minimum pool-size. Note that you need one runner in order
for jobs to be schedulable, else they fail claiming no runners match
the selector labels.
description: Minimum pool-size.
minimum: 0
type: integer
minTtl:
Expand Down
2 changes: 1 addition & 1 deletion controllers/githubactionrunner_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func shouldScaleUp(podRunnerPairs podRunnerPairList, instance *garov1alpha1.Gith
}

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

func (r *GithubActionRunnerReconciler) manageOutcome(ctx context.Context, instance *garov1alpha1.GithubActionRunner, issue error) (reconcile.Result, error) {
Expand Down