Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.netflix.asgard
import com.amazonaws.services.autoscaling.model.AutoScalingGroup
import com.amazonaws.services.autoscaling.model.LaunchConfiguration
import com.amazonaws.services.autoscaling.model.ScheduledUpdateGroupAction
import com.amazonaws.services.autoscaling.model.TagDescription
import com.amazonaws.services.ec2.model.AvailabilityZone
import com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription
import com.amazonaws.services.simpleworkflow.flow.ManualActivityCompletionClient
Expand All @@ -43,6 +44,7 @@ import com.netflix.asgard.push.GroupDeleteOperation
import com.netflix.asgard.push.GroupResizeOperation
import com.netflix.asgard.push.InitialTraffic
import com.netflix.grails.contextParam.ContextParam

import grails.converters.JSON
import grails.converters.XML

Expand Down Expand Up @@ -423,6 +425,8 @@ ${lastGroup.loadBalancerNames}"""
List<ScheduledUpdateGroupAction> newScheduledActions = awsAutoScalingService.copyScheduledActionsForNewAsg(
userContext, nextGroupName, lastScheduledActions)

List<TagDescription> tags = getCopyForwardTags(lastGroup)

Integer lastGracePeriod = lastGroup.healthCheckGracePeriod
String vpcZoneIdentifier = subnets.constructNewVpcZoneIdentifierForPurposeAndZones(subnetPurpose,
selectedZones)
Expand Down Expand Up @@ -474,14 +478,20 @@ Group: ${loadBalancerNames}"""
scheduledActions: newScheduledActions,
vpcZoneIdentifier: vpcZoneIdentifier,
spotPrice: spotPrice,
ebsOptimized: ebsOptimized
ebsOptimized: ebsOptimized,
tags: tags
)
def operation = pushService.startGroupCreate(options)
flash.message = "${operation.task.name} has been started."
redirectToTask(operation.taskId)
}
}

private List<TagDescription> getCopyForwardTags(AutoScalingGroupData asg) {
//Tag keys starting with the String aws are reserved.
List<TagDescription> copyForwardTags = asg?.tags.findAll{ ! it?.key.startsWith("aws") }
}

private int convertToIntOrUseDefault(String value, Integer defaultValue) {
value?.toInteger() ?: defaultValue
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ class GroupCreateOperation extends AbstractPushOperation {
withDefaultCooldown(options.defaultCooldown).withHealthCheckType(options.healthCheckType).
withHealthCheckGracePeriod(options.healthCheckGracePeriod).
withTerminationPolicies(options.terminationPolicies).
withVPCZoneIdentifier(options.vpcZoneIdentifier)
withVPCZoneIdentifier(options.vpcZoneIdentifier).
withTags(options.tags)

LaunchConfiguration launchConfigTemplate = new LaunchConfiguration().withImageId(options.common.imageId).
withKernelId(options.kernelId).withInstanceType(options.common.instanceType).
withKeyName(options.keyName).withRamdiskId(options.ramdiskId).
Expand Down
3 changes: 3 additions & 0 deletions src/groovy/com/netflix/asgard/push/GroupCreateOptions.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
package com.netflix.asgard.push

import com.amazonaws.services.autoscaling.model.ScheduledUpdateGroupAction
import com.amazonaws.services.autoscaling.model.TagDescription
import com.netflix.asgard.model.ScalingPolicyData

import groovy.transform.Immutable

@Immutable final class GroupCreateOptions {
Expand All @@ -35,6 +37,7 @@ import groovy.transform.Immutable
boolean zoneRebalancingSuspended
Collection<ScalingPolicyData> scalingPolicies
Collection<ScheduledUpdateGroupAction> scheduledActions
Collection<TagDescription> tags
String spotPrice
boolean ebsOptimized

Expand Down
11 changes: 10 additions & 1 deletion test/unit/com/netflix/asgard/ClusterControllerSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.netflix.asgard
import com.amazonaws.services.autoscaling.model.AutoScalingGroup
import com.amazonaws.services.autoscaling.model.Instance
import com.amazonaws.services.autoscaling.model.LaunchConfiguration
import com.amazonaws.services.autoscaling.model.TagDescription
import com.netflix.asgard.model.AutoScalingGroupData
import com.netflix.asgard.model.AutoScalingGroupHealthCheckType
import com.netflix.asgard.model.AutoScalingGroupMixin
Expand All @@ -28,6 +29,7 @@ import com.netflix.asgard.model.Subnets
import com.netflix.asgard.push.Cluster
import com.netflix.asgard.push.GroupCreateOperation
import com.netflix.asgard.push.GroupCreateOptions

import grails.test.mixin.TestFor
import spock.lang.Specification
import spock.lang.Unroll
Expand All @@ -46,12 +48,18 @@ class ClusterControllerSpec extends Specification {
subnet('subnet-3', 'us-east-1e', 'internal'),
subnet('subnet-4', 'us-east-1e', 'external'),
])

// Two tags are defined here to ensure that tags beginning with aws are not copied forward as
// they are reserved for AWS internal use, e.g., aws:autoscaling:groupName
final allowedTag = new TagDescription(propagateAtLaunch: true, key: "deployment", value: "test")
final forbiddenTag = new TagDescription(propagateAtLaunch: true, key: "aws:test", value: "aws")

final AutoScalingGroup asg = new AutoScalingGroup(autoScalingGroupName: 'helloworld-example-v015',
minSize: 3, desiredCapacity: 5, maxSize: 7, healthCheckGracePeriod: 42, defaultCooldown: 360,
launchConfigurationName: 'helloworld-lc', healthCheckType: AutoScalingGroupHealthCheckType.EC2,
instances: [new Instance(instanceId: 'i-6ef9f30e'), new Instance(instanceId: 'i-95fe1df6')],
availabilityZones: ['us-east-1c'], loadBalancerNames: ['hello-elb'], terminationPolicies: ['hello-tp'],
vPCZoneIdentifier: 'subnet-1')
vPCZoneIdentifier: 'subnet-1', tags: [allowedTag, forbiddenTag])
final LaunchConfiguration launchConfiguration = new LaunchConfiguration(imageId: 'lastImageId',
instanceType: 'lastInstanceType', keyName: 'lastKeyName', securityGroups: ['sg-123', 'sg-456'],
iamInstanceProfile: 'lastIamProfile', spotPrice: '1.23')
Expand Down Expand Up @@ -166,6 +174,7 @@ class ClusterControllerSpec extends Specification {
assert vpcZoneIdentifier == 'subnet-1'
assert iamInstanceProfile == 'lastIamProfile'
assert spotPrice == '1.23'
assert tags == [allowedTag]
}
true
}) >> { args ->
Expand Down