Jiansen Huang
Jiansen Huang

Reputation: 49

Update AWS ECS service after ECR image being updated

I have ESC service with EC2 task running on an EC2 instance. The image in the EC2 task is from the ECR uri: for example: 688523422345.dkr.ecr.us-west-1.amazonaws.com/image, I noticed that when I load this image into my EC2 task I just directly using the uri:688523422345.dkr.ecr.us-west-1.amazonaws.com/image:latest, because the image uri never changes and I just keep push image to update it.

However, when the image did updated on ECR, the task and service running on EC2 instance doesn't updating. I wondering why, and search on stack overflow, people told me that using aws ecs update-service --cluster <cluster name> --service <service name> --force-new-deployment to force the service to re-deploy. However, I just got error on not enough memory left on the instance(seems the re-deployment will create new task and it keep taking more memories, not a good solution).

How can I solve this?

Upvotes: 1

Views: 1222

Answers (2)

Jiansen Huang
Jiansen Huang

Reputation: 49

It's not working, after tried a lot. I find out is because the EC2 instance already stored all the information from a task(even if deleted task, the instance is still running with the image). The right way to do it is to re-start the instance.

I used aws-cli: aws ec2 reboot-instances --instance-ids <instance_id>

It worked!

Upvotes: 0

Marcin
Marcin

Reputation: 238687

This could be because of your Deployment configuration and the parameters:

  • maximumPercent
  • minimumHealthyPercent

By default minimumHealthyPercent is 100% which means that replacement operation will first attempt to run new tasks, before terminating old ones, potentially resulting in out of memory error. You can set it up to minimumHealthyPercent to 0 and maximumPercent to 100 as to force termination of existing tasks first, before creating new ones.

Upvotes: 1

Related Questions