From 43afbc9c4bb39f02e1d15f59480786035d046842 Mon Sep 17 00:00:00 2001 From: Brent Pitman Date: Fri, 23 Aug 2013 14:07:04 -0700 Subject: [PATCH] Use common functionality in frigga for next asg name. Support user-requested next asg name. --- .../controllers/com/netflix/asgard/ClusterController.groovy | 2 ++ src/groovy/com/netflix/asgard/Relationships.groovy | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/grails-app/controllers/com/netflix/asgard/ClusterController.groovy b/grails-app/controllers/com/netflix/asgard/ClusterController.groovy index da98a2e1..24306de4 100644 --- a/grails-app/controllers/com/netflix/asgard/ClusterController.groovy +++ b/grails-app/controllers/com/netflix/asgard/ClusterController.groovy @@ -394,6 +394,8 @@ ${lastGroup.loadBalancerNames}""" } final String nextGroupName = Relationships.buildNextAutoScalingGroupName(lastGroup.autoScalingGroupName) + if (params.nextAsgName && params.nextAsgName != nextGroupName) + throw new IllegalStateException("Asked for ${params.nextAsgName} but found ${nextGroupName}") List lastScalingPolicies = awsAutoScalingService.getScalingPolicyDatas(userContext, lastGroup.autoScalingGroupName) List newScalingPolicies = lastScalingPolicies.collect { ScalingPolicyData policy -> diff --git a/src/groovy/com/netflix/asgard/Relationships.groovy b/src/groovy/com/netflix/asgard/Relationships.groovy index 080b725b..d042573f 100644 --- a/src/groovy/com/netflix/asgard/Relationships.groovy +++ b/src/groovy/com/netflix/asgard/Relationships.groovy @@ -182,11 +182,7 @@ class Relationships { } static String buildNextAutoScalingGroupName(String previousGroupNameInCluster) { - Names names = dissectCompoundName(previousGroupNameInCluster) - Integer previous = names.sequence - Integer next = (previous == null || previous >= CLUSTER_MAX_SEQUENCE_NUMBER) ? 0 : previous + 1 - String threeDigitNextNumber = String.format("%03d", next) - "${names.cluster}-v${threeDigitNextNumber}" + return AutoScalingGroupNameBuilder.buildNextGroupName(previousGroupNameInCluster) } static String buildLoadBalancerName(String appName, String stack, String detail) {