ECS Deploy Script error "Service not found"

ecr
aws

#1

I’m trying to use the deploy.sh script from the Go Example project that is described in the ECS integration page. Current it isn’t working with an error of

A client error (ServiceNotFoundException) occurred when calling the UpdateService operation: Service not found.
Error updating service.

The images are getting pushed to ECR the Task Definition is getting created and updated accordingly. But the cluster isn’t getting updated automatically with the service. Does the service need to exist in the cluster prior to the deployment happening?


#2

It seems as though yes the Service must be created before hand. Doing this allowed the service to be updated, but it didn’t actually update any of the tasks and ultimately failed with

Service update took too long.

It isn’t clear why the update isn’t happening. In AWS I see the following in the deployment actions

service sample-webapp-service was unable to place a task because no container instance met all of its requirements. The closest matching container-instance XXXXX e is already using a port required by your task. For more information, see the Troubleshooting section.

Any hints to what might be preventing this from updating properly.


#3

So I finally got this working, seemed to be an issue with the Cluster Service having a “Minimum healthy percentage” value set to 50 (the default I believe) and was only running a single EC2 instance for testing which was causing the deployments not to happen. Changing that value down to 0 (just for testing) allowed the deployments to happen.


#4

I’m also experiencing this issue regardless of updating the “Minimum Health Percentage” from “50” to “0”. As well, I added a second EC2 instance to the cluster but the build still failed with the error message “A client error (ServiceNotFoundException) occurred when calling the UpdateService operation: Service not found.
Error updating service.”


#5

Be sure to add the --cluster option to your update-service CLI command if the service you’re looking to update isn’t in the default cluster


#6

Thanks, it resolves my problem when I changed the “Minimum healthy percentage” to 0 ( I have only 1 ec2 instance in my cluster ).


#7

Finally, I can understand why we got this errors

service sample-webapp-service was unable to place a task because no container instance met all of its requirements. The closest matching container-instance XXXXX e is already using a port required by your task. For more information, see the Troubleshooting section.

Actually, it because of the strategy of the settings “Minimum healthy percentage” and “Maximum healthy percentage”.

In my situation, I had 1 cluster contains 2 instances, “Desired count” is 2, “Minimum healthy percent” is 50%, “Maximum healthy percentage” is 200%, “Container Port Mappings” is 80:3000.

Once I update the service with the new task definition, now the “healthy percentage” is 100%, it doesn’t achieve 200%, so the service won’t stop the running task (container), conversely it will run another container in on of the 2 instances. But there had been a container existing used the port 80 in this instance, so definitely we will get the error above.

So I downgrade the value of “Maximum healthy percentage” to 100%, then I did the same operation, the service will stop 1 task and start a new one, then stop another old running task, start another new one.

Additionally, if you use “Load Balancing” for service, we should pay attention to the attribute “Deregistration delay” of a target group, because it will decide after how many time a task (container) will be stopped.


#8

Closing this thread now as it is CircleCI 1.0 specific. The recommended way forwards is to use CircleCI 2.0 as described here: https://circleci.com/blog/aws-ecr-auth-support/ for deploying to ECS from ECR.


#9