-
Notifications
You must be signed in to change notification settings - Fork 319
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
Namespaces for Container Label Keys #660
Conversation
Disclaimer: I am currently a little unsure about the lifecycle aspects of this PR: Adding the prefix to the label keys must be (more or less) considered an incompatible change. Though, we are not aware of any consumer of the labels besides ourselves. As such, the (consistent) change of this constant value would not be harming as such. However, with this change applied, we assume that at the point of time the update happens, no containers are left on the docker instance. Otherwise, those docker containers would get "lost". @pjdarton: What is the committment to our consumers and the administrators w.r.t. updating this plugin? Is there a committment out there that we must be "blue/green deployable"? |
I think that the labels that the plugin puts on it's containers could be considered private to the plugin. As for loosing containers: a plugin upgrade requires a Jenkins restart; restarts will (normally) happen only once no build jobs are running; docker containers get terminated at the end of a build; so, under normal circumstances, we won't lose containers as there won't be any to lose. i.e. I think we should be ok. |
Ok, thanks for the feedback. Besides that, any other comments, e.g. on coding level? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I agree with what's being done here, but we need to undo the code churn on the import statements and the changelog.
* | ||
* Label keys defined in this interface already have this namespace prefixed. | ||
*/ | ||
static final String PLUGIN_LABEL_KEY_NAMESPACE = "com.nirima.jenkins.plugins.docker."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be visible outside this class.
I would also question if it would, in fact, be better to use .class.getPackage().getCanonicalName() + "."
instead of hard-coding the text.
(I can see arguments for & against; I'm not too fussed either way, just as long as both options have been considered)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be visible outside this class.
public
interfaces in java do not permit to specify an attribute to be private. It'll mean that we would have to make it an abstract class
, which also has a co-notation which I don't like (as we don't want to implement this artifact at all anyway).
On the other hand, we have the counter-example already in this plugin with com.nirima.jenkins.plugins.docker.utils.Consts
. If we already have an approach for such cases, we should stick to one concept. I have adjusted it with 30c937b .
.class.getPackage().getCanonicalName() + "."
I did not think over that aspect too much yet. The only thing is that I always dislike, if constants change their value. That might happen, if someone is moving our own namespace around. However, on the other side, if somebody changes the namespace of this plugin, then it'll also be a good idea, if the constants will change (as most likely the "new version" of the plugin will be "something different").
I browsed a little through the coding. My impression is that it more tends to the concept of class-based reference than to absolute referencing. That is why I have adjusted the coding accordingly with 983fdc3.
CHANGELOG.md
Outdated
@@ -1,5 +1,16 @@ | |||
# Changelog | |||
|
|||
## 1.1.x [draft only!] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this detailed explanation is best left to the PR description for this PR.
The changelog should just be one-line summaries with links to additional information as 99% of readers won't care about the details.
Also, I think it's best to leave updating the changelog itself to immediately after the official release because otherwise we might confuse people - the official wiki page links to this file in the master branch so the moment I merge changes it'll be visible to the masses, and folks will assume that if they have the latest release, they'll have all the changes listed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is wh I had marked it as "[draft only!]".
But I am ok with it that we remove the stuff in CHANGELOG.md
and move it to a comment here.
I have done so with b058509
import java.util.Collections; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Set; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you've allowed your IDE to re-arrange all the import statements here.
This makes it very difficult to see what changes have actually been made.
I'm not against changes that re-arrange the code for aesthetic reasons, but they should be kept separate from functional changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will comply to your request, but still I think it's wrong:
You are right that I have set up my IDE to automatically adjust imports. Imports, IMO, are (usually) just syntactic sugar, which I, as developer, do not need to take care of (I have plenty other things to do). These kind of activities do not change anything on semantic level.
If, by chance of this PR, we also clean up the code and don't need to start the entire CI for such a small thing, then this is good (I'd understand your concerns, if I had changed something in the coding, e.g. changes on sequence of methods, or such-a-like).
Would you have approved a PR, with only these aesthetic changes, if I had sent it separately?
reverted with 4ae4722
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is to ensure that important changes are kept to a minimalist set of changed lines of code so that they're easy to merge and will only cause merge conflicts of there is an actual conflict of functionality.
Aesthetic changes are also necessary to keep the code from getting too ugly but they do tend to touch lots and lots of lines of code when they happen, so they're almost impossible to merge with anything, so it's important that nobody ever needs to, which means that these kinds of changes have to be kept apart from functionality changes.
i.e. if you find the code intolerably ugly when working, and can't bear the thought of leaving it like that, do a tidy-up PR first ... or afterwards ... but not at the same time ;-)
import java.util.Map; | ||
|
||
import static org.apache.commons.lang.StringUtils.isEmpty; | ||
import static org.apache.commons.lang.StringUtils.trimToNull; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import statement re-arrangement should not be part of this PR.
(Personally, I prefer to have static imports at the start too, but this is not what this PR is for)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above.
Conflicts: CHANGELOG.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all comments worked on. Back to you...
import java.util.Map; | ||
|
||
import static org.apache.commons.lang.StringUtils.isEmpty; | ||
import static org.apache.commons.lang.StringUtils.trimToNull; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above.
import java.util.Collections; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Set; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will comply to your request, but still I think it's wrong:
You are right that I have set up my IDE to automatically adjust imports. Imports, IMO, are (usually) just syntactic sugar, which I, as developer, do not need to take care of (I have plenty other things to do). These kind of activities do not change anything on semantic level.
If, by chance of this PR, we also clean up the code and don't need to start the entire CI for such a small thing, then this is good (I'd understand your concerns, if I had changed something in the coding, e.g. changes on sequence of methods, or such-a-like).
Would you have approved a PR, with only these aesthetic changes, if I had sent it separately?
reverted with 4ae4722
* | ||
* Label keys defined in this interface already have this namespace prefixed. | ||
*/ | ||
static final String PLUGIN_LABEL_KEY_NAMESPACE = "com.nirima.jenkins.plugins.docker."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be visible outside this class.
public
interfaces in java do not permit to specify an attribute to be private. It'll mean that we would have to make it an abstract class
, which also has a co-notation which I don't like (as we don't want to implement this artifact at all anyway).
On the other hand, we have the counter-example already in this plugin with com.nirima.jenkins.plugins.docker.utils.Consts
. If we already have an approach for such cases, we should stick to one concept. I have adjusted it with 30c937b .
.class.getPackage().getCanonicalName() + "."
I did not think over that aspect too much yet. The only thing is that I always dislike, if constants change their value. That might happen, if someone is moving our own namespace around. However, on the other side, if somebody changes the namespace of this plugin, then it'll also be a good idea, if the constants will change (as most likely the "new version" of the plugin will be "something different").
I browsed a little through the coding. My impression is that it more tends to the concept of class-based reference than to absolute referencing. That is why I have adjusted the coding accordingly with 983fdc3.
CHANGELOG.md
Outdated
@@ -1,5 +1,16 @@ | |||
# Changelog | |||
|
|||
## 1.1.x [draft only!] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is wh I had marked it as "[draft only!]".
But I am ok with it that we remove the stuff in CHANGELOG.md
and move it to a comment here.
I have done so with b058509
As by-product of #658, we have detected that https://docs.docker.com/config/labels-custom-metadata/ requests consumers of docker to use namespaces for their container label keys.
This PR proposes to prefix container label keys used with
com.nirima.jenkins.plugins.docker.
.Moreover, it refactors the existing coding such that all labels are centrally available at a constant interface.
Mapping between old and new label keys