From ba2cb02bbcadb771cd864909abf352ffa578fcf2 Mon Sep 17 00:00:00 2001 From: Richard87 Date: Wed, 11 Sep 2024 13:03:17 +0200 Subject: [PATCH] Allow scaling reconciling component, block scaling jobs --- api/environments/component_handler.go | 8 ++++---- api/environments/environment_handler.go | 4 ---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/api/environments/component_handler.go b/api/environments/component_handler.go index 58e7f9a9..a2a8e56c 100644 --- a/api/environments/component_handler.go +++ b/api/environments/component_handler.go @@ -36,15 +36,15 @@ func (eh EnvironmentHandler) ScaleComponent(ctx context.Context, appName, envNam if replicas > maxScaleReplicas { return environmentModels.CannotScaleComponentToMoreThanMaxReplicas(appName, envName, componentName, maxScaleReplicas) } - log.Ctx(ctx).Info().Msgf("Scaling component %s, %s to %d replicas", componentName, appName, replicas) updater, err := eh.getRadixCommonComponentUpdater(ctx, appName, envName, componentName) if err != nil { return err } - componentStatus := updater.getComponentStatus() - if !radixutils.ContainsString(validaStatusesToScaleComponent, componentStatus) { - return environmentModels.CannotScaleComponent(appName, envName, componentName, componentStatus) + if updater.getComponentToPatch().GetType() == v1.RadixComponentTypeJob { + return environmentModels.JobComponentCanOnlyBeRestarted() } + + log.Ctx(ctx).Info().Msgf("Scaling component %s, %s to %d replicas", componentName, appName, replicas) return eh.patchRadixDeploymentWithReplicas(ctx, updater, &replicas) } diff --git a/api/environments/environment_handler.go b/api/environments/environment_handler.go index 0665ed7e..696e8726 100644 --- a/api/environments/environment_handler.go +++ b/api/environments/environment_handler.go @@ -89,14 +89,10 @@ type EnvironmentHandler struct { ComponentStatuser deploymentModels.ComponentStatuserFunc } -var validaStatusesToScaleComponent []string - // Init Constructor. // Use the WithAccounts configuration function to configure a 'ready to use' EnvironmentHandler. // EnvironmentHandlerOptions are processed in the sequence they are passed to this function. func Init(opts ...EnvironmentHandlerOptions) EnvironmentHandler { - validaStatusesToScaleComponent = []string{deploymentModels.ConsistentComponent.String(), deploymentModels.StoppedComponent.String()} - eh := EnvironmentHandler{ ComponentStatuser: deploymentModels.ComponentStatusFromDeployment, }