Skip to content

Commit

Permalink
fix(aws): Continue if launch configuration already exists (#2376)
Browse files Browse the repository at this point in the history
It's possible that a launch configuration can be created but subsequently
fail due to a network blip.

When this happens, AWS will reject any subsequent requests with an
`AlreadyExistsException` exception.

In such situations, it makes sense to continue (launch configurations
are timestamped down to the second) rather than fail the task.
  • Loading branch information
ajordens committed Feb 16, 2018
1 parent f3f44ad commit 3ceb6fc
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
package com.netflix.spinnaker.clouddriver.aws.deploy

import com.amazonaws.services.autoscaling.AmazonAutoScaling
import com.amazonaws.services.autoscaling.model.AlreadyExistsException
import com.amazonaws.services.autoscaling.model.BlockDeviceMapping
import com.amazonaws.services.autoscaling.model.CreateLaunchConfigurationRequest
import com.amazonaws.services.autoscaling.model.Ebs
import com.amazonaws.services.autoscaling.model.InstanceMonitoring
import com.amazonaws.services.autoscaling.model.LaunchConfiguration
import com.netflix.spinnaker.clouddriver.aws.AwsConfiguration.DeployDefaults
import com.netflix.spinnaker.clouddriver.aws.deploy.LaunchConfigurationBuilder.LaunchConfigurationSettings
import com.netflix.spinnaker.clouddriver.aws.deploy.userdata.LocalFileUserDataProperties
import com.netflix.spinnaker.clouddriver.aws.deploy.userdata.UserDataProvider
import com.netflix.spinnaker.clouddriver.aws.model.AmazonBlockDevice
Expand Down Expand Up @@ -273,13 +273,17 @@ class DefaultLaunchConfigurationBuilder implements LaunchConfigurationBuilder {
request.withBlockDeviceMappings(mappings)
}

OperationPoller.retryWithBackoff({o ->
CreateLaunchConfigurationRequest debugRequest = request.clone()
debugRequest.setUserData(null);
log.debug("Creating launch configuration (${name}): ${debugRequest}")
try {
OperationPoller.retryWithBackoff({ o ->
CreateLaunchConfigurationRequest debugRequest = request.clone()
debugRequest.setUserData(null);
log.debug("Creating launch configuration (${name}): ${debugRequest}")

autoScaling.createLaunchConfiguration(request)
}, 1500, 3);
autoScaling.createLaunchConfiguration(request)
}, 1500, 3);
} catch (AlreadyExistsException e) {
log.debug("Launch configuration already exists, continuing... (${e.message})")
}

name
}
Expand Down

0 comments on commit 3ceb6fc

Please sign in to comment.