Tasks stucks in PENDING
Hi. Have 49 tasks on one cluster with one instance All works fine until today we restart the instance (early all was ok after restart). And all the tasks shows with PENDING status. We start manually all containers and ecs agent (we need them, production server) - but it still pending.
ecs agent versiont was 1.8.1 docker 1.9.1
Updating ecs agent to 1.10 not helping
docker logs ecs-agent
2016-06-03T13:55:55Z [INFO] Starting Agent: Amazon ECS Agent - v1.10.0 (9a1b0f6)
2016-06-03T13:55:55Z [INFO] Loading configuration
2016-06-03T13:55:55Z [WARN] Invalid value for task cleanup duration, will be overridden to 3h0m0s, parsed value 0, minimum threshold 1m0s
2016-06-03T13:55:55Z [INFO] Checkpointing is enabled. Attempting to load state
2016-06-03T13:55:55Z [INFO] Loading state! module="statemanager"
2016-06-03T13:55:55Z [INFO] Restored cluster 'main_gps_receiver'
2016-06-03T13:55:55Z [INFO] Detected Docker versions [1.17 1.18 1.19 1.20 1.21]
2016-06-03T13:55:55Z [INFO] Restored from checkpoint file. I am running as 'arn:aws:ecs:eu-west-1:558122141955:container-instance/dad35cdb-6d77-42f2-be5b-32b8327dcbab' in cluster 'main_gps_receiver'
2016-06-03T13:55:56Z [INFO] Registered! module="api client"
2016-06-03T13:55:56Z [INFO] Saving state! module="statemanager"
2016-06-03T13:55:56Z [INFO] Beginning Polling for updates
2016-06-03T13:55:56Z [INFO] Initializing stats engine module="stats"
2016-06-03T13:55:56Z [INFO] Creating poll dialer module="ws client" host="ecs-t-2.eu-west-1.amazonaws.com"
2016-06-03T13:55:56Z [INFO] Creating poll dialer module="ws client" host="ecs-a-2.eu-west-1.amazonaws.com"
2016-06-03T14:10:19Z [INFO] Creating poll dialer module="ws client" host="ecs-a-2.eu-west-1.amazonaws.com"
2016-06-03T14:22:56Z [INFO] Creating poll dialer module="ws client" host="ecs-t-2.eu-west-1.amazonaws.com"
2016-06-03T14:35:32Z [INFO] Creating poll dialer module="ws client" host="ecs-a-2.eu-west-1.amazonaws.com"
2016-06-03T14:49:56Z [INFO] Creating poll dialer module="ws client" host="ecs-t-2.eu-west-1.amazonaws.com"
2016-06-03T15:00:56Z [INFO] Creating poll dialer module="ws client" host="ecs-t-2.eu-west-1.amazonaws.com"
2016-06-03T15:02:23Z [INFO] Creating poll dialer module="ws client" host="ecs-a-2.eu-west-1.amazonaws.com"
2016-06-03T15:17:56Z [INFO] Creating poll dialer module="ws client" host="ecs-t-2.eu-west-1.amazonaws.com"
@ynelin Thank you for reporting this issue. Can you please confirm if this instance was launched using an AMI that was snapshotted/created from an EC2 Instance that was used to run ECS Tasks?
Around the same time it seems we also see the same pending tasks failed to reach running state. Since we use ECS service, we killed the tasks but the new tasks are still pending. The docker images are locked ( docker images shows label <none> and can't be deleted with docker rmi). We did destroyed the instance and the newly spawned one seems to be working fine.
See this forum thread/message for details on the issue and a workaround until the underlying issue in the ecs-agent is fixed: https://forums.aws.amazon.com/thread.jspa?messageID=724298򰵊
We have identified a problem where pending tasks are not reaching some newly launched instances using an AMI that was created from an instance that had already run tasks with ECS. We are actively working on addressing the issue and will update this thread as more information becomes available. When the issue has been resolved, your tasks that are currently stuck in PENDING will proceed normally on existing connected instances; no action is required on your part.
If you are creating an AMI, you can avoid this problem by ensuring that the ECS agent state file is deleted before snapshotting and creating the AMI. This file is usually located at /var/lib/ecs/data/ecs_agent_data.json.
You can perform the following steps to recover an instance that is currently experiencing problems:
- Stop the ECS agent (you can use
sudo stop ecson an AMI based on Amazon Linux ordocker stopfor a non-Amazon Linux instance) - Edit the agent state file to set the
ACSSeqNumfield to0. This file is usually located at/var/lib/ecs/data/ecs_agent_data.json - Start the ECS agent (you can use
sudo start ecson an AMI based on Amazon Linux or thedocker runcommand you initially used to start the agent on a non-Amazon Linux instance)
Thank you for bringing this to our attention.
Sam
@aaithal originally it was 2015.09.b.
Trying now to reboot instance - and all containers are started up by agent. I don't touch anything. So, I think, guys fixed the problem
We have resolved the issue where pending tasks were not reaching some instances. Tasks that were stuck in PENDING should proceed normally on existing connected instances without any additional action.
Having run ECS for a few months now, we've had a handful of instances which refuse to deploy tasks. They get stuck "PENDING" indefinitely. Manually stopping the task usually sees it distributed onto another instance. Sometimes it'll start on the same instance again and end up PENDING again.
The only full resolution I've found is restarting the instance, but eventually one of our instances will start suffering from the problem again. We've seen this in both our production and QA environment. We're presently running amzn-ami-2016.09.b-amazon-ecs-optimized (ami-a1491ad2). We've seen this issue 4 times in the past 4 months. A total of 12 instances running concurrently. So ~8% of our instances will suffer this issue per month.
Looking at the logs I can see the poisoned instance had a dramatic change in network out a few days ago compared to the rest of the instances, though ECS still seems to be able to talk to it and ask it to run tasks. The loadbalancers aren't complaining about anything either.