Terminating EC2 Instance in ASG without Shrinking ASG
Issue Summary:
When terminating EC2 instances via the AWS Console or API's there are generally 2 options.
- Terminate EC2 immediately, this is available for raw EC2 and ASG EC2 Instances. This does not trigger any termination lifecycle hook.
- Terminate EC2 in ASG, this is only for ASG EC2 instances and will trigger any termination lifecycle hook configured.
Both options have their use case. This issue is about the second case, terminating EC2 Instances in an ASG.
Currently the UI has a:
Terminate instanceoption which uses raw EC2 termination - not honouring lifecycle hooks. https://github.com/spinnaker/clouddriver/blob/c9c9608b58d9c48ccd6545c9acdb632ebaa67c1f/clouddriver-aws/src/main/groovy/com/netflix/spinnaker/clouddriver/aws/deploy/ops/TerminateInstancesAtomicOperation.groovy#L18Terminate and shrink ASGoption which uses ASG termination and honours lifecycle hooks. https://github.com/spinnaker/clouddriver/blob/c9c9608b58d9c48ccd6545c9acdb632ebaa67c1f/clouddriver-aws/src/main/groovy/com/netflix/spinnaker/clouddriver/aws/deploy/ops/TerminateInstanceAndDecrementAsgAtomicOperation.groovy#L22
Option 1 is useful when the instance can be destroyed without customer impact.
Option 2 is safer as it will engage any lifecycle hook and drain customer sessions.
However we don't always want to shrink the ASG.
It would be nice to be able to select in the UI whether we want to use withShouldDecrementDesiredCapacity(Boolean shouldDecrementDesiredCapacity) or not per Javadoc - TerminateInstanceInAutoScalingGroupRequest.
Perhaps add a new option Terminate in Autoscaling Group:
Terminate<< unchangedTerminate in Server Group<< new optionTerminate and Shrink Server Group<< unchanged
Are we open to a PR? And do I need to plumb through Clouddriver <- Gate <- Deck ?
Cloud Provider(s):
AWS EC2
Environment:
Spinnaker 1.24.2 on Kubernetes
Feature Area:
UI, possibly pipelines
Description:
Steps to Reproduce:
- deploy AWS EC2 ASG
- navigate to Infrastructure -> Clusters
- select an instance and click
Instance Actions - choose
Terminate and Shrink Server Group
Source: spinnaker/spinnaker