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, }