Closed AbhishekRana95 closed 4 years ago
@borsothy I have addressed all your comments. Please let me know if anything else needs to be changed.
I was looking around and found https://github.com/acquia/moonshot/blob/ab44b072e82747eccddb59b6afc081b4ae5524d7/docs/plugins/asg_rollout.md. I could not dig deeper, but can you take a look that plugin and check if we are not duplicating the same behaviour or if we can extend it's behaviour.
This asg_rollout is introducing a new instance in ASG first and then removing the old instance. Let me see if I am able to reuse this and if not then find the reason why. Thank you for pointing this out @kaushik 💯
I was looking around and found https://github.com/acquia/moonshot/blob/ab44b072e82747eccddb59b6afc081b4ae5524d7/docs/plugins/asg_rollout.md. I could not dig deeper, but can you take a look that plugin and check if we are not duplicating the same behaviour or if we can extend it's behaviour.
This asg_rollout is introducing a new instance in ASG first and then removing the old instance. Let me see if I am able to reuse this and if not then find the reason why. Thank you for pointing this out @kaushik 💯
@kaushik there is a case in this that suppose there is no outdated instances in the ASG at the moment and we run bundle exec moonshot update
in the repo. What happens is it first increase the desired capacity by 1, wait for and add an instance and then start the logic where it finds the outdated instances if not then what it does is that it decreases the capacity by 1 i.e. getting it back to normal. When the capacity is brought back to normal what AWS does is it terminates one of the instance in respond to the change and this termination is not doing it in the way we want and doing it according to the AWS termination logic which might lead to abruptly stopping the instance which might be executing some workflow at the time.
Let me know your thoughts on this 🤔
Manually reviewed! Verified instance was properly stopped, removed, and rotated.
Console output
|gloria.lee| |cloudservicesdev| (master)$ [2020/10/12-16:22:03]\ in ~/Desktop/Database/cloud-database-worker
→ bundle exec moonshot update -n dev-gloria1
[ ✓ ] [ 0m 0s ] Using existing KMS Key for ParameterKMS!
[ ✓ ] [ 0m 1s ] Using previous encrypted value for NewRelicLicenseKey.
[ ✓ ] [ 0m 12s ] ChangeSet moonshot-cdb-worker-dev-gloria1-1602534307 ready!
* Modify LaunchConfig (AWS::AutoScaling::LaunchConfiguration)
- Will be replaced
- Caused by template change (Properties: ImageId)
* Modify WorkerASG (AWS::AutoScaling::AutoScalingGroup)
- May be replaced (Conditional)
- Caused by LaunchConfig (ResourceReference)
Apply changes? yes
[ ✓ ] [ 0m 0s ] Executed ChangeSet moonshot-cdb-worker-dev-gloria1-1602534307 for CloudFormation Stack cdb-worker-dev-gloria1.
[ ✓ ] [ 0m 22s ] CloudFormation Stack cdb-worker-dev-gloria1 successfully updated.
[ ✓ ] [ 0m 1s ] CodeDeploy Application cdb-worker-dev-gloria1 already exists.
[ ✓ ] [ 0m 0s ] CodeDeploy CodeDeploy Deployment Group cdb-worker-dev-gloria1 already exists.
[ ✓ ] [ 0m 0s ] AutoScaling Group(s) up to capacity!
[ ✓ ] [ 0m 1s ] Uploading 'cdb-worker_1602534353_gloria.lee.tar.gz' to 'cdb-stack-resource-backups-dev' succeeded.
[ ✓ ] [ 4m 25s ] ASG instances rotated successfully!
[ ✓ ] [ 0m 2s ] Outdated instances removed successfully!
In AWS console
Before update
After update Outdated instance successfully shut down:
New instance created/rotation completed:
Change: minor Purpose: feature
Manual review steps:
c.plugins << Moonshot::Plugins::RotateAsgInstances.new
to the file.cdb-worker.json
and change the AMIs.cd cloud-database-worker && bundle exec moonshot update
CloudFormation > Stacks > cdb-worker-dev-#{stack_name}
where stack_name is your worker stack.