diff --git a/api/v1alpha1/githubactionrunner_types.go b/api/v1alpha1/githubactionrunner_types.go index c9453198..70596a48 100644 --- a/api/v1alpha1/githubactionrunner_types.go +++ b/api/v1alpha1/githubactionrunner_types.go @@ -18,7 +18,7 @@ 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 @@ -26,7 +26,7 @@ type GithubActionRunnerSpec struct { 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"` diff --git a/config/crd/bases/garo.tietoevry.com_githubactionrunners.yaml b/config/crd/bases/garo.tietoevry.com_githubactionrunners.yaml index 6dec2ca6..68f19c07 100644 --- a/config/crd/bases/garo.tietoevry.com_githubactionrunners.yaml +++ b/config/crd/bases/garo.tietoevry.com_githubactionrunners.yaml @@ -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: diff --git a/controllers/githubactionrunner_controller.go b/controllers/githubactionrunner_controller.go index 400aca3d..bf735799 100644 --- a/controllers/githubactionrunner_controller.go +++ b/controllers/githubactionrunner_controller.go @@ -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) {