Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jenkinsfile: avoid container collisions (unique tags) #1112

Merged
merged 1 commit into from
Jan 13, 2017

Conversation

aduermael
Copy link
Contributor

@aduermael aduermael commented Jan 12, 2017

Proposed changes

Added one command in the Jenkinsfile to remove all Docker containers that might be present before running the tests. (because we've had issues where the container name was already taken)
sh "docker rm -fv $(docker ps -a -q)"

Now tagging images and containers with JOB_BASE_NAME and BUILD_NUMBER to avoid collisions.

cc @joaofnfernandes

@joaofnfernandes
Copy link
Contributor

I don't have much experience with Jenkins, but this might cause parallel jobs running on the same machine to interfere with one another.
Example

  1. Build 1 starts serving the docs container and starts running the tests
  2. While this is happening, build 2 is scheduled to the same machine. It removes the docs container and proceeds to create a new one and run the tests
  3. Build 1 fails because there is no container serving the docs. Depending on how things get scheduled it might also happen that the tests on build 1 are running against docs from build 2.

Not sure if this is a real problem or not. If it is, we can consider tagging the docs container as docs-<commit-hash>.

container_name=docs-$(git rev-parse HEAD)

@aduermael
Copy link
Contributor Author

@joaofnfernandes oh... I don't have much experience with Jenkins either. I thought each build was made in its own clean environment. I work too much with Docker... 😋
You're right I'll do that differently, using a unique tag for the docs container.

@sanscontext
Copy link
Contributor

@aduermael +1 giving each one a PR/build-specific container name would probably both fix the current issue we're having and also make cleanup easier if container delete fails afterwards somehow. :)

@aduermael
Copy link
Contributor Author

@sanscontext ok, I'll see what I can do!

@joaofnfernandes
Copy link
Contributor

Looks good to me!

Signed-off-by: Adrien Duermael <adrien@duermael.com>
@aduermael aduermael changed the title Jenkinsfile: cleanup docker containers Jenkinsfile: avoid container collisions (unique tags) Jan 13, 2017
@sanscontext
Copy link
Contributor

LGTM, but like @joaofnfernandes I don't have a lot of experience with Jenkins. Should we call @mikedougherty for a look?

@aduermael
Copy link
Contributor Author

@sanscontext I ended up using environment variables that are available in the build context, nothing fancy. Just waiting for tests to pass, then it can be merged.

@aduermael
Copy link
Contributor Author

🙄

Could not update commit status. Message: GitHub API rate limit exceeded

Finished: SUCCESS

@johndmulhausen
Copy link

Is all of Docker using one API key? Might be at the point where we need to break it up. :/

@aduermael
Copy link
Contributor Author

Oh! All checks have passed!
Can someone merge it please?

@joaofnfernandes joaofnfernandes merged commit 6f512f6 into docker:master Jan 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants