Skip to content

Commit

Permalink
Allow scaling reconciling component, block scaling jobs (#672)
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard87 authored Sep 12, 2024
1 parent b1de696 commit 0732e20
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 4 additions & 4 deletions api/environments/component_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
4 changes: 0 additions & 4 deletions api/environments/environment_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down

0 comments on commit 0732e20

Please sign in to comment.