Skip to content

Commit

Permalink
fix(trafficguards): Fix Moniker usage in instance termination (spinna…
Browse files Browse the repository at this point in the history
…ker#1781)

The instance termination task does not normally have a `serverGroupName`
explicitly specified.

Without such, the moniker used to check traffic guards is invalid.
  • Loading branch information
ajordens authored Nov 8, 2017
1 parent 15ab8b9 commit 52823d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@ public void verifyInstanceTermination(String serverGroupNameFromStage,

instancesPerServerGroup.entrySet().forEach(entry -> {
String serverGroupName = entry.getKey();
if (hasDisableLock(serverGroupMonikerFromStage, account, location)) {
Moniker moniker = serverGroupMonikerFromStage;
if (moniker.getApp() == null) {
// handle scenarios where the stage moniker is invalid (ie. stage had no server group details provided)
moniker = MonikerHelper.friggaToMoniker(serverGroupName);
}

if (hasDisableLock(moniker, account, location)) {
Optional<TargetServerGroup> targetServerGroup = oortHelper.getTargetServerGroup(account, serverGroupName, location.getValue(), cloudProvider);

targetServerGroup.ifPresent(serverGroup -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class TrafficGuardSpec extends Specification {
otherServerGroup.instances = [[name: "i-1", healthState: "Down"]]

when:
trafficGuard.verifyInstanceTermination(null, moniker, ["i-1"], "test", location, "aws", "x")
trafficGuard.verifyInstanceTermination(null, MonikerHelper.friggaToMoniker(null), ["i-1"], "test", location, "aws", "x")

then:
thrown(IllegalStateException)
Expand Down

0 comments on commit 52823d6

Please sign in to comment.