Skip to content

Commit

Permalink
fix(titus): respect applicationDefaultSecurityGroup when cloning (#2620)
Browse files Browse the repository at this point in the history
persists the decision to not create an applicationDefaultSecurityGroup in titus attribute
  • Loading branch information
tomaslin committed May 10, 2018
1 parent 10bbce9 commit a0bfdd5
Showing 1 changed file with 22 additions and 1 deletion.
Expand Up @@ -59,6 +59,8 @@ import org.springframework.beans.factory.annotation.Autowired
@Slf4j
class TitusDeployHandler implements DeployHandler<TitusDeployDescription> {

public static final String USE_APPLICATION_DEFAULT_SG_LABEL = 'spinnaker.useApplicationDefaultSecurityGroup'

@Autowired
AwsLookupUtil awsLookupUtil

Expand Down Expand Up @@ -178,6 +180,9 @@ class TitusDeployHandler implements DeployHandler<TitusDeployDescription> {
}
}
}
if (sourceJob.labels?.get(USE_APPLICATION_DEFAULT_SG_LABEL) == "false") {
description.useApplicationDefaultSecurityGroup = false
}
}

task.updateStatus BASE_PHASE, "Preparing deployment to ${account}:${region}${subnet ? ':' + subnet : ''}..."
Expand All @@ -187,6 +192,22 @@ class TitusDeployHandler implements DeployHandler<TitusDeployDescription> {
description.labels.put("interestingHealthProviderNames", description.interestingHealthProviderNames.join(","))
}

if (description.labels.containsKey(USE_APPLICATION_DEFAULT_SG_LABEL)) {
if (description.labels.get(USE_APPLICATION_DEFAULT_SG_LABEL) == "false") {
description.useApplicationDefaultSecurityGroup = false
} else {
description.useApplicationDefaultSecurityGroup = true
}
}

if (description.useApplicationDefaultSecurityGroup == false) {
description.labels.put(USE_APPLICATION_DEFAULT_SG_LABEL, "false")
} else {
if (description.labels.containsKey(USE_APPLICATION_DEFAULT_SG_LABEL)) {
description.labels.remove(USE_APPLICATION_DEFAULT_SG_LABEL)
}
}

SubmitJobRequest submitJobRequest = new SubmitJobRequest()
.withApplication(description.application)
.withDockerImageName(dockerImage.imageName)
Expand Down Expand Up @@ -301,7 +322,7 @@ class TitusDeployHandler implements DeployHandler<TitusDeployDescription> {
} catch (io.grpc.StatusRuntimeException e) {
task.updateStatus BASE_PHASE, "Error encountered submitting job request to Titus ${e.message} for ${nextServerGroupName}"
if ((e.status.code == Status.RESOURCE_EXHAUSTED.code && e.status.description.contains("Constraint violation - job with group sequence")) || (e.status.code == Status.INVALID_ARGUMENT.code && e.status.description.contains("Job sequence id reserved by another pending job"))) {
if (e.status.code == Status.INVALID_ARGUMENT){
if (e.status.code == Status.INVALID_ARGUMENT) {
sleep 1000 ^ pow(2, retryCount)
retryCount++
}
Expand Down

0 comments on commit a0bfdd5

Please sign in to comment.