[Request] Support ECS cluster auto scaling configurations
See original GitHub issueI know this was already somewhat addressed in #151, however the plugin does not seem to support cluster auto scaling configurations where desired count is zero.
I have an EC2-backed cluster with cluster auto scaling configured with a desired count of zero on the underlying Auto Scaling group. If I run a task within that cluster using the RunTask API action, the task goes into a PROVISIONING state while ECS tells the ASG an instance is needed. The task then runs once an instance is fully booted and available within the cluster.
With this setup, however, the plugin throws an error if it sees no container instances available in the cluster:
2020-05-20 15:48:03.187+0000 [id=266] WARNING c.c.j.p.amazonecs.ECSLauncher#launch: [JenkinsBuild-ec2-generic-fhldc]: Error in provisioning; agent=com.cloudbees.jenkins.plugins.amazonecs.ECSSlave[JenkinsBuild-ec2-generic-fhldc]
com.amazonaws.services.ecs.model.InvalidParameterException: No Container Instances were found in your cluster. (Service: AmazonECS; Status Code: 400; Error Code: InvalidParameterException; Request ID: ...)
Would it be possible to support this scenario by detecting the presence of an ECS capacity provider with cluster auto scaling and, instead of failing, waiting for ECS to do its thing?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:8 (1 by maintainers)

Top Related StackOverflow Question
I did some more thorough testing with ECS cluster auto scaling. The plugin’s current requirement of
launchTypenot only breaks configurations where no instances are running in the cluster, it also breaks scale-out entirely when managed scaling is enabled, even with instances running in the cluster already. Here is an example:Configuration
cpu: 0.25memoryReservation: 512Desired Behavior
PROVISIONINGstatus.Actual Behavior
As you can see, no cluster auto scaling occurs because Jenkins cannot place tasks for which no instance capacity exists into the
PROVISIONINGstatus necessary for managed scaling to work.This issue is similar to #138 (same cause, different effect). In order for the plugin to support cluster auto scaling, it must support capacity providers and do several things:
capacityProviderStrategyas an alternative tolaunchTypein task templates and usewithCapacityProviderStrategyin theRunTaskAPI request. This would support configurations where multiple capacity providers are available for use on the cluster.launchTypeANDcapacityProviderStrategyin task templates and construct the API request with NEITHERwithLaunchTypeNORwithCapacityProviderStrategyso that thedefaultCapacityProviderStrategyon the cluster takes over. This would support configurations where the default capacity provider strategy on the cluster is always desirable.launchTypeis null. This would ensure that Jenkins does not retain builds in its queue when capacity is not available and a capacity provider is handling scaling.This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.