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

Support setting additional labels on slave containers #747

Merged
merged 1 commit into from
Sep 10, 2019

Conversation

francoisferrand
Copy link
Contributor

@francoisferrand francoisferrand commented Sep 4, 2019

This patch adds an extraLabels fields to DockerTemplateBase, which is used to specify additional docker labels to set on slave containers.

This can be used for example to logically group containers, or to setup scheduling constraints on swarm.

See also: https://issues.jenkins-ci.org/browse/JENKINS-45227

Copy link
Member

@pjdarton pjdarton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two main issues:

  1. Naming
    Choosing names for things is never as straightforward as it could be and, sadly, this is no exception 😬
    Slave nodes (and templates that create them) already have a field for "labels", so having a field called "extraLabels" sounds like it's going to add to the labels field rather than the docker container labels.
    I think we need a big rename here and call the new field "extraDockerLabels" rather than just "extraLabels" (plus extra text in the html help file).
    Hopefully a big search & replace turning xtraLabels to xtraDockerLabels will do 95% of the work...

  2. Configuration round trip
    The getter/setter pairing turns nulls to empties and hashCode/equals treats this as a change, resulting in a unit-test failure: https://ci.jenkins.io/job/Plugins/job/docker-plugin/view/change-requests/job/PR-747/1/testReport/
    Either persist nulls as nulls and empties as empties ... or ensure that empties are always stored as nulls.
    Personally, I quite like the idea of absent/unused configuration fields simply not appearing at all in the saved config (as it makes for smaller more efficient files), which means we need nulls when we're turned into XML.

@pjdarton
Copy link
Member

pjdarton commented Sep 5, 2019

Thanks for the PR - enhancements such as this are always welcome 😀

I've done a review - please resolve the changes requested and ping me once you think it's there.

Hint: If the automated build on ci.jenkins.io fails for reasons that you don't think are your fault, you can make it retry the build by closing the PR, waiting 10 minutes, and then re-opening the PR again (you don't need to create a new PR). You can also do a local build & test by doing mvn install on a linux machine that's got Java 8, [a recent] maven and [a recent] docker installed.

@pjdarton pjdarton added the enhancement A PR providing an enhancement to existing functionality. label Sep 5, 2019
Copy link
Member

@pjdarton pjdarton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the doCheckExtraDockerLabelsString method.

@francoisferrand francoisferrand force-pushed the extraLabels branch 2 times, most recently from 470ccee to 019e659 Compare September 10, 2019 14:16
@francoisferrand
Copy link
Contributor Author

All changes done, can you please review?

@pjdarton pjdarton merged commit ac7d142 into jenkinsci:master Sep 10, 2019
@francoisferrand francoisferrand deleted the extraLabels branch September 16, 2019 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A PR providing an enhancement to existing functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants