Skip to content
Merged
2 changes: 2 additions & 0 deletions internal/pkg/deploy/cloudformation/stack/backend_svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func (s *BackendService) Template() (string, error) {
desiredCountOnSpot = advancedCount.Spot
capacityProviders = advancedCount.Cps
}

entrypoint, err := convertEntryPoint(s.manifest.EntryPoint)
if err != nil {
return "", err
Expand All @@ -133,6 +134,7 @@ func (s *BackendService) Template() (string, error) {
EnvControllerLambda: envControllerLambda.String(),
Storage: convertStorageOpts(s.manifest.Name, s.manifest.Storage),
Network: convertNetworkConfig(s.manifest.Network),
DeploymentConfiguration: convertDeploymentConfig(s.manifest.DeployConfig),
EntryPoint: entrypoint,
Command: command,
DependsOn: convertDependsOn(s.manifest.ImageConfig.Image.DependsOn),
Expand Down
7 changes: 7 additions & 0 deletions internal/pkg/deploy/cloudformation/stack/backend_svc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ Outputs:
StringSlice: []string{"here"},
}
svc.manifest.ExecuteCommand = manifest.ExecuteCommand{Enable: aws.Bool(true)}
svc.manifest.DeployConfig = manifest.DeploymentConfiguration{
Rolling: aws.String("recreate"),
}
},
mockDependencies: func(t *testing.T, ctrl *gomock.Controller, svc *BackendService) {
m := mocks.NewMockbackendSvcReadParser(ctrl)
Expand All @@ -213,6 +216,10 @@ Outputs:
SubnetsType: template.PrivateSubnetsPlacement,
SecurityGroups: []string{"sg-1234"},
},
DeploymentConfiguration: template.DeploymentConfigurationOpts{
MinHealthyPercent: 0,
MaxPercent: 100,
},
EntryPoint: []string{"enter", "from"},
Command: []string{"here"},
}).Return(&template.Content{Buffer: bytes.NewBufferString("template")}, nil)
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/deploy/cloudformation/stack/lb_web_svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ func (s *LoadBalancedWebService) Template() (string, error) {
Platform: convertPlatform(s.manifest.Platform),
HTTPVersion: convertHTTPVersion(s.manifest.RoutingRule.ProtocolVersion),
NLB: nlbConfig.settings,
DeploymentConfiguration: convertDeploymentConfig(s.manifest.DeployConfig),
AppDNSName: nlbConfig.appDNSName,
AppDNSDelegationRole: nlbConfig.appDNSDelegationRole,
NLBCertValidatorFunctionLambda: nlbConfig.certValidatorLambda,
Expand Down
8 changes: 8 additions & 0 deletions internal/pkg/deploy/cloudformation/stack/lb_web_svc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ Outputs:
AssignPublicIP: template.EnablePublicIP,
SubnetsType: template.PublicSubnetsPlacement,
},
DeploymentConfiguration: template.DeploymentConfigurationOpts{
MinHealthyPercent: 100,
MaxPercent: 200,
},
EntryPoint: []string{"/bin/echo", "hello"},
Command: []string{"world"},
ALBEnabled: true,
Expand Down Expand Up @@ -272,6 +276,10 @@ Outputs:
AssignPublicIP: template.EnablePublicIP,
SubnetsType: template.PublicSubnetsPlacement,
},
DeploymentConfiguration: template.DeploymentConfigurationOpts{
MinHealthyPercent: 100,
MaxPercent: 200,
},
EntryPoint: []string{"/bin/echo", "hello"},
Command: []string{"world"},
ALBEnabled: true,
Expand Down
20 changes: 20 additions & 0 deletions internal/pkg/deploy/cloudformation/stack/transformers.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ const (
capacityProviderFargate = "FARGATE"
)

// MinimumHealthyPercent and MaximumPercent configurations as per deployment strategy.
const (
minHealthyPercentRecreate = 0
maxPercentRecreate = 100
minHealthyPercentDefault = 100
maxPercentDefault = 200
)

var (
taskDefOverrideRulePrefixes = []string{"Resources", "TaskDefinition", "Properties"}
)
Expand Down Expand Up @@ -609,6 +617,18 @@ func convertEntryPoint(entrypoint manifest.EntryPointOverride) ([]string, error)
return out, nil
}

func convertDeploymentConfig(deploymentConfig manifest.DeploymentConfiguration) template.DeploymentConfigurationOpts {
var deployConfigs template.DeploymentConfigurationOpts
if strings.EqualFold(aws.StringValue(deploymentConfig.Rolling), manifest.ECSRecreateRollingUpdateStrategy) {
deployConfigs.MinHealthyPercent = minHealthyPercentRecreate
deployConfigs.MaxPercent = maxPercentRecreate
} else {
deployConfigs.MinHealthyPercent = minHealthyPercentDefault
deployConfigs.MaxPercent = maxPercentDefault
}
return deployConfigs
}

func convertCommand(command manifest.CommandOverride) ([]string, error) {
out, err := command.ToStringSlice()
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/pkg/deploy/cloudformation/stack/worker_svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func (s *WorkerService) Template() (string, error) {
desiredCountOnSpot = advancedCount.Spot
capacityProviders = advancedCount.Cps
}

entrypoint, err := convertEntryPoint(s.manifest.EntryPoint)
if err != nil {
return "", err
Expand Down Expand Up @@ -135,6 +136,7 @@ func (s *WorkerService) Template() (string, error) {
BacklogPerTaskCalculatorLambda: backlogPerTaskLambda.String(),
Storage: convertStorageOpts(s.manifest.Name, s.manifest.Storage),
Network: convertNetworkConfig(s.manifest.Network),
DeploymentConfiguration: convertDeploymentConfig(s.manifest.DeployConfig),
EntryPoint: entrypoint,
Command: command,
DependsOn: convertDependsOn(s.manifest.ImageConfig.Image.DependsOn),
Expand Down
7 changes: 7 additions & 0 deletions internal/pkg/deploy/cloudformation/stack/worker_svc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ Outputs:
StringSlice: []string{"here"},
}
svc.manifest.ExecuteCommand = manifest.ExecuteCommand{Enable: aws.Bool(true)}
svc.manifest.DeployConfig = manifest.DeploymentConfiguration{
Rolling: aws.String("default"),
}
},
mockDependencies: func(t *testing.T, ctrl *gomock.Controller, svc *WorkerService) {
m := mocks.NewMockworkerSvcReadParser(ctrl)
Expand Down Expand Up @@ -217,6 +220,10 @@ Outputs:
SubnetsType: template.PrivateSubnetsPlacement,
SecurityGroups: []string{"sg-1234"},
},
DeploymentConfiguration: template.DeploymentConfigurationOpts{
MinHealthyPercent: 100,
MaxPercent: 200,
},
EntryPoint: []string{"enter", "from"},
Command: []string{"here"},
}).Return(&template.Content{Buffer: bytes.NewBufferString("template")}, nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ exec: true # Enable running commands in your container.
# You can override any of the values defined above by environment.
#environments:
# test:
# count: 2 # Number of tasks to run for the "test" environment.
# count: 2 # Number of tasks to run for the "test" environment.
# deployment: # The deployment strategy for the "test" environment.
# rolling: 'recreate' # Stops existing tasks before new ones are started for faster deployments.
4 changes: 3 additions & 1 deletion internal/pkg/manifest/testdata/backend-svc-nohealthcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ exec: true # Enable running commands in your container.
# You can override any of the values defined above by environment.
#environments:
# test:
# count: 2 # Number of tasks to run for the "test" environment.
# count: 2 # Number of tasks to run for the "test" environment.
# deployment: # The deployment strategy for the "test" environment.
# rolling: 'recreate' # Stops existing tasks before new ones are started for faster deployments.
2 changes: 2 additions & 0 deletions internal/pkg/manifest/testdata/lb-svc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ exec: true # Enable running commands in your container.
#environments:
# test:
# count: 2 # Number of tasks to run for the "test" environment.
# deployment: # The deployment strategy for the "test" environment.
# rolling: 'recreate' # Stops existing tasks before new ones are started for faster deployments.
2 changes: 2 additions & 0 deletions internal/pkg/manifest/testdata/worker-svc-nosubscribe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ exec: true # Enable running commands in your container.
#environments:
# test:
# count: 2 # Number of tasks to run for the "test" environment.
# deployment: # The deployment strategy for the "test" environment.
# rolling: 'recreate' # Stops existing tasks before new ones are started for faster deployments.
2 changes: 2 additions & 0 deletions internal/pkg/manifest/testdata/worker-svc-subscribe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ subscribe:
#environments:
# test:
# count: 2 # Number of tasks to run for the "test" environment.
# deployment: # The deployment strategy for the "test" environment.
# rolling: 'recreate' # Stops existing tasks before new ones are started for faster deployments.
2 changes: 1 addition & 1 deletion internal/pkg/manifest/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var (
dependsOnValidStatuses = []string{dependsOnStart, dependsOnComplete, dependsOnSuccess, dependsOnHealthy}
nlbValidProtocols = []string{TCP, tls}
TracingValidVendors = []string{awsXRAY}
ecsRollingUpdateStrategies = []string{ecsDefaultRollingUpdateStrategy, ecsRecreateRollingUpdateStrategy}
ecsRollingUpdateStrategies = []string{ECSDefaultRollingUpdateStrategy, ECSRecreateRollingUpdateStrategy}

httpProtocolVersions = []string{"GRPC", "HTTP1", "HTTP2"}

Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/manifest/workload_ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const (
MinWindowsTaskMemory = 2048

// deployment strategies
ecsDefaultRollingUpdateStrategy = "default"
ecsRecreateRollingUpdateStrategy = "recreate"
ECSDefaultRollingUpdateStrategy = "default"
ECSRecreateRollingUpdateStrategy = "recreate"
)

// Platform related settings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ DeploymentConfiguration:
DeploymentCircuitBreaker:
Enable: true
Rollback: true
MinimumHealthyPercent: 100
MaximumPercent: 200
MinimumHealthyPercent: {{ .DeploymentConfiguration.MinHealthyPercent }}
MaximumPercent: {{ .DeploymentConfiguration.MaxPercent }}
PropagateTags: SERVICE
{{- if .ExecuteCommand }}
EnableExecuteCommand: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ exec: true # Enable running commands in your container.
# You can override any of the values defined above by environment.
#environments:
# test:
# count: 2 # Number of tasks to run for the "test" environment.
# count: 2 # Number of tasks to run for the "test" environment.
# deployment: # The deployment strategy for the "test" environment.
# rolling: 'recreate' # Stops existing tasks before new ones are started for faster deployments.
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ exec: true # Enable running commands in your container.
#environments:
# test:
# count: 2 # Number of tasks to run for the "test" environment.
# deployment: # The deployment strategy for the "test" environment.
# rolling: 'recreate' # Stops existing tasks before new ones are started for faster deployments.
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ subscribe:
#environments:
# test:
# count: 2 # Number of tasks to run for the "test" environment.
# deployment: # The deployment strategy for the "test" environment.
# rolling: 'recreate' # Stops existing tasks before new ones are started for faster deployments.
21 changes: 15 additions & 6 deletions internal/pkg/template/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,14 @@ type ObservabilityOpts struct {
Tracing string // The name of the vendor used for tracing.
}

// DeploymentConfiguraitonOpts holds values for MinHealthyPercent and MaxPercent.
type DeploymentConfigurationOpts struct {
// The lower limit on the number of tasks that should be running during a service deployment or when a container instance is draining.
MinHealthyPercent int
// The upper limit on the number of tasks that should be running during a service deployment or when a container instance is draining.
MaxPercent int
}

// ExecuteCommandOpts holds configuration that's needed for ECS Execute Command.
type ExecuteCommandOpts struct{}

Expand Down Expand Up @@ -471,12 +479,13 @@ type WorkloadOpts struct {
ALBEnabled bool

// Additional options for service templates.
WorkloadType string
HealthCheck *ContainerHealthCheck
HTTPHealthCheck HTTPHealthCheckOpts
DeregistrationDelay *int64
AllowedSourceIps []string
NLB *NetworkLoadBalancer
WorkloadType string
HealthCheck *ContainerHealthCheck
HTTPHealthCheck HTTPHealthCheckOpts
DeregistrationDelay *int64
AllowedSourceIps []string
NLB *NetworkLoadBalancer
DeploymentConfiguration DeploymentConfigurationOpts

// Lambda functions.
RulePriorityLambda string
Expand Down