fix(ecs): Add validation for loadBalancedContainer when using artifact
MODIFY
clouddriver-ecs/src/main/java/com/netflix/spinnaker/clouddriver/ecs/deploy/validators/EcsCreateServerGroupDescriptionValidator.java
clouddriver-ecs/src/main/java/com/netflix/spinnaker/clouddriver/ecs/deploy/validators/EcsCreateServerGroupDescriptionValidator.java
@@ -122,6 +122,18 @@ public class EcsCreateServerGroupDescriptionValidator extends CommonValidator {
} else {
rejectValue(errors, "reservedMemory", "not.nullable");
}
+ } else {
+ // Verify load balanced services w/ an artifact specify which container to load balance on
+ boolean hasTargetGroup =
+ createServerGroupDescription.getTargetGroup() != null
+ && !createServerGroupDescription.getTargetGroup().isEmpty();
+ boolean hasLoadBalancedContainer =
+ createServerGroupDescription.getLoadBalancedContainer() != null
+ && !createServerGroupDescription.getLoadBalancedContainer().isEmpty();
+
+ if (hasTargetGroup && !hasLoadBalancedContainer) {
+ rejectValue(errors, "loadBalancedContainer", "not.nullable");
+ }
}
if (createServerGroupDescription.getContainerPort() != null) {

MODIFY
clouddriver-ecs/src/test/groovy/com/netflix/spinnaker/clouddriver/ecs/deploy/validators/EcsCreateServergroupDescriptionValidatorSpec.groovy
clouddriver-ecs/src/test/groovy/com/netflix/spinnaker/clouddriver/ecs/deploy/validators/EcsCreateServergroupDescriptionValidatorSpec.groovy
@@ -119,6 +119,19 @@ class EcsCreateServergroupDescriptionValidatorSpec extends AbstractValidatorSpec
0 * errors.rejectValue(_, _)
}
+ void '(with artifact) should fail when load balancer specified but loadBalanced container missing'() {
+ given:
+ def description = getDescription()
+ description.useTaskDefinitionArtifact = true
+ def errors = Mock(Errors)
+
+ when:
+ validator.validate([], description, errors)
+
+ then:
+ 1 * errors.rejectValue('loadBalancedContainer', "${getDescriptionName()}.loadBalancedContainer.not.nullable")
+ }
+
@Override
AbstractECSDescription getNulledDescription() {
def description = (CreateServerGroupDescription) getDescription()

fix(ecs): Add validation for loadBalancedContainer when using artifact (#3888)