From 80de00e9c3fc1eb0cd37a80e0548d96fbdd6cdab Mon Sep 17 00:00:00 2001 From: "David J. M. Karlsen" Date: Sun, 5 Jun 2022 20:28:04 +0200 Subject: [PATCH 1/3] this comment is no longer true --- api/v1alpha1/githubactionrunner_types.go | 2 +- config/crd/bases/garo.tietoevry.com_githubactionrunners.yaml | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/api/v1alpha1/githubactionrunner_types.go b/api/v1alpha1/githubactionrunner_types.go index c9453198..4c19e808 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 diff --git a/config/crd/bases/garo.tietoevry.com_githubactionrunners.yaml b/config/crd/bases/garo.tietoevry.com_githubactionrunners.yaml index 6dec2ca6..2a4354df 100644 --- a/config/crd/bases/garo.tietoevry.com_githubactionrunners.yaml +++ b/config/crd/bases/garo.tietoevry.com_githubactionrunners.yaml @@ -55,9 +55,7 @@ spec: 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: From 66653aa9fcd391c262034fb35b651d8e11d150ca Mon Sep 17 00:00:00 2001 From: "David J. M. Karlsen" Date: Sun, 5 Jun 2022 20:57:29 +0200 Subject: [PATCH 2/3] allow scale to zero --- controllers/githubactionrunner_controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) { From 68daee39295953c8a1ebf301cd7d4665c75fd724 Mon Sep 17 00:00:00 2001 From: "David J. M. Karlsen" Date: Sun, 5 Jun 2022 21:06:32 +0200 Subject: [PATCH 3/3] max can be set to zero now too --- api/v1alpha1/githubactionrunner_types.go | 2 +- config/crd/bases/garo.tietoevry.com_githubactionrunners.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/v1alpha1/githubactionrunner_types.go b/api/v1alpha1/githubactionrunner_types.go index 4c19e808..70596a48 100644 --- a/api/v1alpha1/githubactionrunner_types.go +++ b/api/v1alpha1/githubactionrunner_types.go @@ -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 2a4354df..68f19c07 100644 --- a/config/crd/bases/garo.tietoevry.com_githubactionrunners.yaml +++ b/config/crd/bases/garo.tietoevry.com_githubactionrunners.yaml @@ -51,7 +51,7 @@ spec: type: string maxRunners: description: Maximum pool-size. Must be greater or equal to minRunners - minimum: 1 + minimum: 0 type: integer minRunners: default: 1