question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Regression - Externally-managed ECS task definitions don't work with inheritFrom

See original GitHub issue

There appears to have been a regression from version 1.24 onwards impacting management the deletion of task definitions when externally-managed ECS task definitions are being used. I can confirm that if you use agent { label 'name-of-my-externally-manged-ecs-agent'} it works but it did break a bunch of pipelines that we had configured with the previous agent { ecs { inheritFrom 'name-of-my-externally-manged-ecs-agent' } }. The agent is being executed, the steps in the stage are also executed but the pipeline fails when the agents are being destroyed. There are no issues with using inheritFrom with policies defined in the plugin config and managed by the plugin with and without overwriting properties. Here is an anonymised stacktrace from the logs of the plugin.

Delete ECS agent task: arn:aws:ecs:us-east-1:aws_account_id:task/task_id
Jan 17, 2020 2:00:09 PM INFO com.cloudbees.jenkins.plugins.amazonecs.pipeline.ECSTaskTemplateStepExecution$ECSTaskTemplateCallback finished
Removing task template my-template-name from cloud my-ecs-cloud
Jan 17, 2020 2:00:09 PM FINE com.cloudbees.jenkins.plugins.amazonecs.ECSCloud
Selected Region: us-east-1
Jan 17, 2020 2:00:09 PM FINE com.cloudbees.jenkins.plugins.amazonecs.ECSCloud
Selected Region: us-east-1
Jan 17, 2020 2:00:10 PM FINE com.cloudbees.jenkins.plugins.amazonecs.ECSLauncher
[my-ecs-cloud-testp-115-xlx3c-wcg6z]: Status of ECS Task is PENDING
Jan 17, 2020 2:00:10 PM INFO com.cloudbees.jenkins.plugins.amazonecs.ECSLauncher launch
[my-ecs-cloud-testp-115-xlx3c-wcg6z]: Waiting for agent to start
Jan 17, 2020 2:00:10 PM FINE com.cloudbees.jenkins.plugins.amazonecs.ECSCloud
No existing task definition found for family or ARN: my-ecs-cloud-my-template-name
com.amazonaws.services.ecs.model.ClientException: Unable to describe task definition. (Service: AmazonECS; Status Code: 400; Error Code: ClientException; Request ID: 7b5f77d2-477b-4a27-8d51-edd21747bbdb)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1726)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1381)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1127)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:784)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:752)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:726)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:686)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:668)
	at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:532)
	at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:512)
	at com.amazonaws.services.ecs.AmazonECSClient.doInvoke(AmazonECSClient.java:4233)
	at com.amazonaws.services.ecs.AmazonECSClient.invoke(AmazonECSClient.java:4200)
	at com.amazonaws.services.ecs.AmazonECSClient.invoke(AmazonECSClient.java:4189)
	at com.amazonaws.services.ecs.AmazonECSClient.executeDescribeTaskDefinition(AmazonECSClient.java:1632)
	at com.amazonaws.services.ecs.AmazonECSClient.describeTaskDefinition(AmazonECSClient.java:1602)
	at com.cloudbees.jenkins.plugins.amazonecs.ECSService.findTaskDefinition(ECSService.java:302)
	at com.cloudbees.jenkins.plugins.amazonecs.ECSService.removeTemplate(ECSService.java:281)
	at com.cloudbees.jenkins.plugins.amazonecs.ECSCloud.removeDynamicTemplate(ECSCloud.java:379)
	at com.cloudbees.jenkins.plugins.amazonecs.pipeline.ECSTaskTemplateStepExecution$ECSTaskTemplateCallback.finished(ECSTaskTemplateStepExecution.java:196)
	at org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback$TailCall.onSuccess(BodyExecutionCallback.java:118)
	at org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$SuccessAdapter.receive(CpsBodyExecution.java:377)
	at com.cloudbees.groovy.cps.Outcome.resumeFrom(Outcome.java:73)
	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:166)
	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
	at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
	at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:405)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:317)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:281)
	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
	at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Jan 17, 2020 2:00:10 PM INFO com.cloudbees.jenkins.plugins.amazonecs.ECSService findTaskDefinition
No existing task definition found for family or ARN: my-ecs-cloud-my-template-name

Plugin version 1.24 and 1.26 tested. Jenkins ver. 2.204.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
webratzcommented, Jan 20, 2020

Hey, I currently don’t have time to work a lot on the plugin, but I’m glad to merge a PR with tests for that issue and release as fast as possible.

1reaction
wuillaumcommented, Jan 17, 2020

Likely due to this change

https://github.com/jenkinsci/amazon-ecs-plugin/commit/8d74e145039ee985e110b99801f7f122f7f69504

To fix the regression, both getInheritFrom() and getTaskDefinitionOverride() must be done, with appropriate logic handling the possible cases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Task definition parameters - Amazon Elastic Container Service
When a new task starts, the Amazon ECS container agent pulls the latest version of the specified image and tag for the container...
Read more >
Running Jenkins jobs in AWS ECS with slave agents
create task definitions – a task definition is a description of an ECS task that will at some point be run. It contains...
Read more >
Amazon Elastic Container Service (ECS) / Fargate
This Jenkins plugin uses Amazon Elastic Container Service to host jobs ... use this ECS cluster and will create automatically the required Task...
Read more >
8 Common Mistakes When Using AWS ECS to Manage ...
What are the potential pitfalls when configuring AWS ECS task definitions? Learn more about the best practices of working with containers >>
Read more >
Writing Task Definitions for Amazon ECS - YouTube
Learn more about defining Tasks in the AWS documentation at http://amzn.to/2CMDjvk.Get sample task definitions for common applications at ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found