Skip to content

Commit

Permalink
Rethrow exception so it can be properly handled by orca
Browse files Browse the repository at this point in the history
  • Loading branch information
xavileon committed Oct 28, 2019
1 parent c3bf766 commit c7cd134
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.netflix.spinnaker.clouddriver.aws.deploy.ops;

import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.cloudformation.AmazonCloudFormation;
import com.amazonaws.services.cloudformation.model.*;
import com.netflix.spinnaker.clouddriver.aws.deploy.description.DeleteCloudFormationChangeSetDescription;
Expand Down Expand Up @@ -56,14 +57,14 @@ public Map operate(List priorOutputs) {
try {
task.updateStatus(BASE_PHASE, "Deleting CloudFormation ChangeSet");
amazonCloudFormation.deleteChangeSet(deleteChangeSetRequest);
} catch (AmazonCloudFormationException e) {
} catch (AmazonServiceException e) {
log.error(
"Error removing change set "
+ description.getChangeSetName()
+ " on stack "
+ description.getStackName(),
e);
return Collections.emptyMap();
throw e;
}
return Collections.emptyMap();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@

package com.netflix.spinnaker.clouddriver.aws.deploy.ops

import com.amazonaws.AmazonServiceException
import com.amazonaws.services.cloudformation.AmazonCloudFormation
import com.amazonaws.services.cloudformation.model.*
import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.spinnaker.clouddriver.aws.TestCredential
import com.netflix.spinnaker.clouddriver.aws.deploy.description.DeleteCloudFormationChangeSetDescription
import com.netflix.spinnaker.clouddriver.aws.deploy.description.DeployCloudFormationDescription
import com.netflix.spinnaker.clouddriver.aws.security.AmazonClientProvider
import com.netflix.spinnaker.clouddriver.data.task.Task
import com.netflix.spinnaker.clouddriver.data.task.TaskRepository
import spock.lang.Specification
import spock.lang.Unroll

class DeleteCloudFormationChangeSetAtomicOperationSpec extends Specification {
void setupSpec() {
Expand Down Expand Up @@ -62,4 +60,37 @@ class DeleteCloudFormationChangeSetAtomicOperationSpec extends Specification {
}
}

void "should propagate exceptions when deleting the change set"() {
given:
def amazonClientProvider = Mock(AmazonClientProvider)
def amazonCloudFormation = Mock(AmazonCloudFormation)
def op = new DeleteCloudFormationChangeSetAtomicOperation(
new DeleteCloudFormationChangeSetDescription(
[
stackName: "stackTest",
changeSetName: "changeSetName",
region: "eu-west-1",
credentials: TestCredential.named("test")
]
)
)
op.amazonClientProvider = amazonClientProvider
def exception = new AmazonServiceException("error")

when:
try {
op.operate([])
}
catch (Exception e) {
e instanceof AmazonServiceException
}

then:
1 * amazonClientProvider.getAmazonCloudFormation(_, _) >> amazonCloudFormation
1 * amazonCloudFormation.deleteChangeSet(_) >> {
throw exception
}
}


}

0 comments on commit c7cd134

Please sign in to comment.