Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ec2-resource-agent: deregister as ECS instance before termination #720

Merged
merged 1 commit into from
Dec 20, 2022

Conversation

etungsten
Copy link
Contributor

Before we terminate the EC2 instance, if the instance was previous registered as a ECS container instance, kick off ECS container instance deregisteration before terminating the EC2 instance.

Issue number:
Resolves #717

Description of changes:

    ec2-resource-agent: deregister as ECS instance before termination
    
    Before we terminate the EC2 instance, if the instance was previous
    registered as a ECS container instance, kick off ECS container instance
    deregisteration before terminating the EC2 instance.

Testing done:

EC2 resource agent for ECS clusters delete cleanly and ensures all ECS container instances are de-registered with a 5 min timeout that doesn't error and proceeds to terminate the EC2 instance.

[2022-12-20T02:41:23Z INFO  resource_agent::agent] Initializing Agent
[2022-12-20T02:41:23Z INFO  ec2_resource_agent::ec2_provider] Kicked-off ECS instance deregistration for 'arn:aws:ecs:us-west-2::container-instance/aarch64-aws-ecs-1-nvidia/bcdc114aa81f4b3eb0287b0a6a
c8360b'
[2022-12-20T02:41:23Z INFO  ec2_resource_agent::ec2_provider] Kicked-off ECS instance deregistration for 'arn:aws:ecs:us-west-2::container-instance/aarch64-aws-ecs-1-nvidia/1dcbd507512149e2ae86aa71fc
801db1'
[bottlerocket/agents/src/bin/ec2-resource-agent/ec2_provider.rs:657] listed_instances = [
    "arn:aws:ecs:us-west-2::container-instance/aarch64-aws-ecs-1-nvidia/1dcbd507512149e2ae86aa71fc801db1",
    "arn:aws:ecs:us-west-2::container-instance/aarch64-aws-ecs-1-nvidia/bcdc114aa81f4b3eb0287b0a6ac8360b",
]
[bottlerocket/agents/src/bin/ec2-resource-agent/ec2_provider.rs:658] container_instances = [
    "arn:aws:ecs:us-west-2::container-instance/aarch64-aws-ecs-1-nvidia/bcdc114aa81f4b3eb0287b0a6ac8360b",
    "arn:aws:ecs:us-west-2::container-instance/aarch64-aws-ecs-1-nvidia/1dcbd507512149e2ae86aa71fc801db1",
]
...
[bottlerocket/agents/src/bin/ec2-resource-agent/ec2_provider.rs:657] listed_instances = []
[bottlerocket/agents/src/bin/ec2-resource-agent/ec2_provider.rs:658] container_instances = [
    "arn:aws:ecs:us-west-2::container-instance/aarch64-aws-ecs-1-nvidia/bcdc114aa81f4b3eb0287b0a6ac8360b",
    "arn:aws:ecs:us-west-2::container-instance/aarch64-aws-ecs-1-nvidia/1dcbd507512149e2ae86aa71fc801db1",
]
[2022-12-20T02:41:38Z INFO  ec2_resource_agent::ec2_provider] All instances created by this resource agent have been deregistered. Proceeding with EC2 instance termination...
[2022-12-20T02:41:38Z INFO  ec2_resource_agent::ec2_provider] Instances deleted

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

Before we terminate the EC2 instance, if the instance was previous
registered as a ECS container instance, kick off ECS container instance
deregisteration before terminating the EC2 instance.
Copy link
Contributor

@ecpullen ecpullen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@stmcginnis stmcginnis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ec2-agent: deregister ECS container instance before terminating
3 participants