awslabs / awslabs/aws-codebuild-jenkins-plugin

ConcurrentModificationException in CodeBuildAction

Open
#54 20 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
156
Forks
130
PR merge metrics
No merged PRs in 30d

Description

I am using:

Jenkins: 2.89.3
AWS Codebuild plugin: com.amazonaws:aws-codebuild:0.17 (maven ID)
Pipeline plugin: org.jenkins-ci.plugins.workflow:workflow-aggregator:2.5 (maven ID)

And I have a multibranch pipeline with Jenkinsfile which looks something like this:

```
pipeline {
agent { label 'master' }

stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Test Run') {
failFast true
parallel {
stage('Test Run 1') {
steps {
timestamps {
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'aws']]) {
awsCodeBuild credentialsId: 'CodeBuild', credentialsType: 'jenkins', projectName: 'Proj1', region: 'us-east-1', sourceControlType: 'project', sourceVersion: "${env.GIT_COMMIT}"
}
}
}
}
stage('Test Run 2') {
steps {
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'aws']]) {
awsCodeBuild credentialsId: 'CodeBuild', credentialsType: 'jenkins', projectName: 'Proj2', region: 'us-east-1', sourceControlType: 'project', sourceVersion: "${env.GIT_COMMIT}"
}
}
}
stage('Test Run 3') {
steps {
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'aws']]) {
awsCodeBuild credentialsId: 'CodeBuild', credentialsType: 'jenkins', projectName: 'Proj3', region: 'us-east-1', sourceControlType: 'project', sourceVersion: "${env.GIT_COMMIT}", envVariables: "[{VAR, value1}]"
}
}
}
stage('Test Run 4') {
steps {
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'aws']]) {
awsCodeBuild credentialsId: 'CodeBuild', credentialsType: 'jenkins', projectName: 'Proj3', region: 'us-east-1', sourceControlType: 'project', sourceVersion: "${env.GIT_COMMIT}", envVariables: "[{VAR, value2}]"
}
}
}
stage('Test Run 5') {
steps {
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'aws']]) {
awsCodeBuild credentialsId: 'CodeBuild', credentialsType: 'jenkins', projectName: 'Proj3', region: 'us-east-1', sourceControlType: 'project', sourceVersion: "${env.GIT_COMMIT}", envVariables: "[{VAR, value3}]"
}
}
}
stage('Test Run 6') {
steps {
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'aws']]) {
awsCodeBuild credentialsId: 'CodeBuild', credentialsType: 'jenkins', projectName: 'Proj3', region: 'us-east-1', sourceControlType: 'project', sourceVersion: "${env.GIT_COMMIT}", envVariables: "[{VAR, value4}]"
}
}
}
}
}
}
}
```

in stages `Test Run 3` to `Test Run 6` I am using same Codebuild project but with different environment variable values which execute different scripts in the build
When I am running the job with above pipeline I am getting following exception:

```
java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:907)
at java.util.ArrayList$Itr.next(ArrayList.java:857)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:73)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
Caused: java.lang.RuntimeException: Failed to serialize CodeBuildAction#logs for class CodeBuildAction
at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
Caused: java.lang.RuntimeException: Failed to serialize hudson.model.Actionable#actions for class org.jenkinsci.plugins.workflow.job.WorkflowRun
at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026)
at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015)
at com.thoughtworks.xstream.XStream.toXML(XStream.java:988)
at hudson.XmlFile.write(XmlFile.java:181)
at org.jenkinsci.plugins.workflow.support.PipelineIOUtils.writeByXStream(PipelineIOUtils.java:30)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.save(WorkflowRun.java:1070)
at hudson.BulkChange.commit(BulkChange.java:98)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.notifyListeners(CpsFlowExecution.java:1377)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$3.run(CpsThreadGroup.java:412)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.run(CpsVmExecutorService.java:35)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
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)
Finished: FAILURE
```

I am not familiar with Jenkins plugins, can anyone suggest any pointers, where can I look for more information, etc.

Contributor guide

Open the contributing guide

Research direction

Start at CodeBuildAction#logs and follow the serialization path shown through XStream, WorkflowRun.save, and PipelineIOUtils.writeByXStream. Reproduce the failure with the parallel Jenkinsfile and confirm that concurrent CodeBuild executions can be persisted without the ConcurrentModificationException while retaining their logs.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, java
Domain
ci-cd, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.