-
Notifications
You must be signed in to change notification settings - Fork 317
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
feat(DockerCloud): option to use docker hostname as slave display name #299
Conversation
Think it should be added to page "Built on Docker" and not slave name. Docker swarm is abstraction layer to avoid such interaction with each concrete host. But the information should be available by request. If this information will be on page for https://github.com/jenkinsci/docker-plugin/blob/master/docker-plugin/src/main/java/com/nirima/jenkins/plugins/docker/action/DockerBuildAction.java - is it solves your problem? |
We like to see the actual host of the build while it runs to easily spot problems. This way we can already see in the Jenkins executor overview when something goes wrong with the scheduling or a host isn't accepting any jobs. As this is an option it is the decision of the user if he wants to see this information or not. |
What kind of problems it helps to solve? Maybe just extend logging? Think hostname exposing is wrong way to research slave provisioning problems |
We just want to quickly see where a job is actually running. This helped us to spot problems early and it adds some useful information to the slave name. |
With this logic it will be useful to add image name, exposed ports, image hash, attached volumes etc :) IMHO If you get regular problems and spot them with help of hostname, probably you do something wrong. |
Sorry, but i wouldn't merge it now, because i plan review swarm integration separately. I will add it to roadmap. Cloud name + container hash is really unique identifier, if you want see more info, then it should be displayed in slave view page (in TODO review this API provided by jenkins: afair you just need extended configure.jelly for slave object). Also plugin has docker cloud page, then is in bad state and may show more advanced info. |
@KostyaSha do you mean #235? Or any specific issue? As #299 is the current one. |
@menski sorry, wrong url in buffer, docker-java/docker-java#299 (seems we have two PRs with the same id?) |
Adds an option to the docker cloud to use the hostname of the docker host as slave display name. If the hostname cannot be resolved the IP address is used. This is useful for setups with docker swarm. The display name of the slave will then contain the information on which actual docker host the job is running. Limitation: The docker container must have a port mapping to get the hostname of the slave.
@menski ^^ |
Because I love to derail things... wouldn't it be better to create a field with that is evaluated with the Token-Macro plugin and then also publish some additional tokens that could be used? I just can't imagine we could possibly come up with a strategy that makes everybody happy, and this way you could create a "sensible default", and then let @menski use hostname if desired, and I could use the name of the committer (since for us, commit = container, and toss them after each job), which I've had at least 5 people independently ask for... |
So anyone who has used docker in production will know precisely why knowing That said, where there's 2 options, there's more than likely >2. I quite then later: other - provides text box to provide a string (expandable then if someone comes up with something un-thought-of, we don't need @menski / @nnordrum - would you be interested in re-spinning the feature in On Tue, Oct 20, 2015 at 10:48 PM, Noah Nordrum notifications@github.com
|
@nnordrum BTW - I don't think you'll be able to name the slave based on the commit (or author) that it's going to build, as that isn't the order of things in Jenkins. Slaves that are provisioned have no knowledge of the build that they are going to execute. |
@magnayn I completely agree at the time of provision, but is there some reason why the slave couldn't rename itself? I'm far from an expert on the internals of jenkins slave naming... I'm basing this almost completely on the fact that the Build Executor Status box's entire innerHTML is replaced from ajaxExecutors, so we should be able to rename the computer/slave/whatever it's called and then it would show up "soon". |
Sure, you could do that - the slave's name can be changed from within the Such a build step though wouldn't be tied neccesarily to docker-plugin On Wed, Oct 21, 2015 at 11:18 PM, Noah Nordrum notifications@github.com
|
I could just add a system groovy command then I bet. any pointers on how to rename a slave? :) Edit: nevermind, was stupidly easy... Jenkins.instance.slaves.first().name = 'test-rename' didn't even look at the API... got it right on the first guess in the Script Console |
ok that didn't work as expected... created a Freestyle Job with an "Execute system Groovy script" step
and an Execute shell step
Fails almost immediately
Any ideas? |
@nnordrum you can't do this. |
@KostyaSha I didn't think you could, but I wasn't really in a position to argue... |
You might be able to get it to work, but it's likely to be a certain amount of pain. The
By changing the slave's name, you're actually changing its whole identity (equals(), hashCode). You might be able to get around this by
Cleanup at the end is likely to be a pig, and you'll either have to change everything that was using the old node id to the new one, or live with 2 slaves until the end (I.E: most objects store ID - String - references to objects that are looked up, rather than direct references) Sounds like too much trouble to me. Things really don't expect the ID to change once it's set, and the slave is always instantiated without any knowledge of what it's about to build. As an aside - you may then see the attractive 'description' field in Slave, only to discover that it's You might want to ask on the ML if it's possible to extend the UI items in the build executor status list (LHS) in the same way that you can add extra status columns for builds, I think that woiuld be generally useful (e.g: not only is this build #117 but it's of PR #32). |
what about
That shouldn't have any of those side effects--right? |
Display names will be the right direction. |
It won't have those side-effects, and sadly it won't work (in that I don't think it will give you what you want). You can override both getDisplayName() and getNodeDescription(). The former isn't used in the UI (It'll simply continue to display cloudname-xxxxxxx). The latter appears if you click the node for it's details (appears in brackets), but after the machine is deleted of course even that disappears. |
Description is different. |
Yes, it should, but it doesn't appear to. I think a wider Jenkins change is the way to go. There are few use-cases here.
#1 can probably be done with either changing the naming policy for the ID, On Mon, Oct 26, 2015 at 9:33 AM, Kanstantsin Shautsou <
|
@magnayn for displayNames i filled https://issues.jenkins-ci.org/browse/JENKINS-31560 , that should be pretty simple change. for 2) It should be done via additional page in jenkins because this small executors list widget will be too overloaded. Showing detailed info makes sense only for those who wants see it. Then such page can operate in the same way as 'Views'. At all it can be just one more view. |
Lol, it already supported. Just Override getDisplayName and additional field in DockerComputer, then set it whenever you want, if you need attach something to build for history, then just append action onTaskCompleted to Run :) |
doesn't seem to be relevant now docker swarm mode supersede docker-swarm |
Adds an option to the docker cloud to use the hostname of the docker
host as slave display name. If the hostname cannot be resolved the IP
address is used.
This is useful for setups with docker swarm. The display name of the
slave will then contain the information on which actual docker host
the job is running.
Limitation: The docker container must have a port mapping to
get the hostname of the slave.