For EC2 launch type I'm able to check agent configuration in /etc/ecs/ecs.config file at EC2 container instance. But is it possible to find out the same info at ECS Fargate Task? For example, I'd like to know, what is the timeout between SIGTERM and SIGKILL (ECS_CONTAINER_STOP_TIMEOUT). I wonder should it be possible to retrieve such info from Amazon ECS Task Metadata Endpoint?
In Fargate, timeout between SIGTERM and SIGKILL is the same as the default setting of 30 seconds.
For newer Fargate platform versions, you can use the stopTimeout container definition parameter. Note the maximum value of 120 seconds:
For tasks that use the Fargate launch type, the task or service requires platform version 1.3.0 or later (Linux) or 1.0.0 or later (for Windows). The max stop timeout value is 120 seconds. However, if the parameter isn't specified, the default value of 30 seconds is used.
Related
I have a cluster running two services, a web app, and a message queue handler. The app has autoscaling configured, but the queue handler does not. There's also a couple of scheduled tasks that run as well.
If I run a task manually using the cli (aws ecs run-task), the task works properly at first, then then after about 5 minutes loses the ability to make outbound connections.
From looking at the scaling logs, it doesn't look like autoscaling would be causing this issue.
I'm running Superset in AWS ECS using Fargate. This instance of Superset is for internal use only. I want to be able to configure ECS to scale to zero tasks when not in use. I am aware that it will take time (Possibly minutes) to come back up, the end-users of this application are content with waiting a few minutes.
Situation:
AWS ECS deployed using Fargate
Autoscaling set to a max of 2 and a min of 0
Want to scale to 0 when not in use (after, say, an hour)
Scaling ECS down to zero when not in use is not possible. ECS is designed to run continuously, unlike Lambda functions that can be turned on and off as requests arrive.
However, if your internal users only access the application during known hours (say business hours), then you can use scheduled scaling to scale to zero during specific hours.
You can use put-scheduled-action for that.
aws application-autoscaling put-scheduled-action --service-namespace ecs \
--schedule "cron(15 12 * * ? *)" \
...
This AWS Blog post explains it in more detail: https://aws.amazon.com/blogs/containers/optimizing-amazon-elastic-container-service-for-cost-using-scheduled-scaling/
I've created a simple task to print a hello world. I've created a ECR image, docker compose and ecs-params.yml.
I get the cloudwatch log for the print, but the task keeps launching every minute, which I guess it's due to REPLICA service type.
How can I stop this from happening, I want to launch this Fargate task ONLY from a lambda, and when it finishes I don't it to be relaunched.
Thanks in advance
If you want a one-shot / one-off / standalone task to be launched by ECS and have it run until it finishes, you wouldn't use an ECS service definition but merely a task.
You can run tasks on their own without packaging as an ECS service.
See: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_run_task.html
If you are using the ECS CLI, then there is also ecs-cli compose create. So, you would use that call and not the one also creating an ECS service along with it.
You can then use AWS Lambda and send an ecs:RunTask AWS API call to invoke/start the ECS task.
I am trying to restart my ECS service. Whenever I issue the below command, it takes 5 minutes for the ECS to re-start service.
aws ecs update-service --service name --force-new-deployment
Note that I mean, ECS does that only after 5 mins. 5 mins wait time seems to be 'draining' phase. However my application does not even process a single request. So why is it waiting for 5 minutes?
How can I forcefully restart immediately via commandline?
The command aws ecs update-service --service name --force-new-deployment execute a simple process:
Start a new task, when the health check marks as healthy the service begins to drain the old task and starts the load balancer to divert the connections towards the new task. For this reason it takes some minutes.
If you want to stop immediately you need to use aws ecs stop-task Check here about it and then start the new task, use aws ecs start-task Check here about it or run-task Check here about it. But you will have a downtime.
I am using rundeck 1.6 version and need to configure timeout option for the rundeck jobs so that when the job exceeds the timeout value, it automatically stops without going to the next step.
Thanks
As 2.7 Rundeck support
Job Timeout
Timeout
You can set a maximum runtime for a job. If the runtime exceeds this value, the job will be halted (as if a user had killed it.) (Note: Timeout only affects the job if is invoked directly, not if it is used as a Job Reference.)
On server from Rundeck installed, alter the file /etc/ssh/ssh_config to:
Host *
ServerAliveInterval 180
ServerAliveCountMax 2