Skip to content

Commit

Permalink
Add rolling blue green strategy flag
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanBorislavovDimitrov committed Aug 14, 2024
1 parent 9969bcb commit 8505fdc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
6 changes: 3 additions & 3 deletions commands/deploy_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ func (c *DeployCommand) GetPluginCommand() plugin.Command {
util.GetShortOption(allModulesOpt): "Deploy all modules which are contained in the deployment descriptor, in the current location",
util.GetShortOption(allResourcesOpt): "Deploy all resources which are contained in the deployment descriptor, in the current location",
util.GetShortOption(retriesOpt): "Retry the operation N times in case a non-content error occurs (default 3)",
util.GetShortOption(strategyOpt): "Specify the deployment strategy when updating an mta (default, blue-green)",
util.GetShortOption(skipTestingPhase): "(STRATEGY: BLUE-GREEN) Do not require confirmation for deleting the previously deployed MTA app",
util.GetShortOption(skipIdleStart): "(STRATEGY: BLUE-GREEN) Directly start the new MTA version as 'live', skipping the 'idle' phase of the resources. Do not require further confirmation or testing before deleting the old version",
util.GetShortOption(strategyOpt): "Specify the deployment strategy when updating an mta (default, blue-green, (EXPERIMENTAL) incremental-blue-green)",
util.GetShortOption(skipTestingPhase): "(STRATEGY: BLUE-GREEN, (EXPERIMENTAL) INCREMENTAL-BLUE-GREEN) Do not require confirmation for deleting the previously deployed MTA app",
util.GetShortOption(skipIdleStart): "(STRATEGY: BLUE-GREEN, (EXPERIMENTAL) INCREMENTAL-BLUE-GREEN) Directly start the new MTA version as 'live', skipping the 'idle' phase of the resources. Do not require further confirmation or testing before deleting the old version",
},
},
}
Expand Down
19 changes: 13 additions & 6 deletions commands/deployment_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ func (d *DeployCommandDeploymentStrategy) CreateProcessBuilder() *util.ProcessBu
}

type BlueGreenDeployCommandDeploymentStrategy struct {
noConfirm bool
skipIdleStart bool
noConfirm bool
skipIdleStart bool
incrementalDeploy bool
}

func (b *BlueGreenDeployCommandDeploymentStrategy) CreateProcessBuilder() *util.ProcessBuilder {
Expand All @@ -30,23 +31,29 @@ func (b *BlueGreenDeployCommandDeploymentStrategy) CreateProcessBuilder() *util.
processBuilder.Parameter("noConfirm", strconv.FormatBool(b.noConfirm))
processBuilder.Parameter("skipIdleStart", strconv.FormatBool(b.skipIdleStart))
processBuilder.Parameter("keepOriginalAppNamesAfterDeploy", strconv.FormatBool(true))
processBuilder.Parameter("shouldApplyIncrementalInstancesUpdate", strconv.FormatBool(b.incrementalDeploy))
return processBuilder
}

func NewDeploymentStrategy(flags *flag.FlagSet, typeProvider ProcessTypeProvider) DeploymentStrategy {
if typeProvider.GetProcessType() == (blueGreenDeployCommandProcessTypeProvider{}).GetProcessType() {
return &BlueGreenDeployCommandDeploymentStrategy{GetBoolOpt(noConfirmOpt, flags), GetBoolOpt(skipIdleStart, flags)}
return &BlueGreenDeployCommandDeploymentStrategy{GetBoolOpt(noConfirmOpt, flags), GetBoolOpt(skipIdleStart, flags), isIncrementalBlueGreen(flags)}
}
strategy := GetStringOpt(strategyOpt, flags)
if strategy == "default" {
return &DeployCommandDeploymentStrategy{}
}
if GetBoolOpt(skipIdleStart, flags) {
return &BlueGreenDeployCommandDeploymentStrategy{true, true}
return &BlueGreenDeployCommandDeploymentStrategy{true, true, isIncrementalBlueGreen(flags)}
}
return &BlueGreenDeployCommandDeploymentStrategy{GetBoolOpt(skipTestingPhase, flags), false}
return &BlueGreenDeployCommandDeploymentStrategy{GetBoolOpt(skipTestingPhase, flags), false, isIncrementalBlueGreen(flags)}
}

func isIncrementalBlueGreen(flags *flag.FlagSet) bool {
strategy := GetStringOpt(strategyOpt, flags)
return strategy == "incremental-blue-green"
}

func AvailableStrategies() []string {
return []string{"blue-green", "default"}
return []string{"blue-green", "incremental-blue-green", "default"}
}

0 comments on commit 8505fdc

Please sign in to comment.