-
Notifications
You must be signed in to change notification settings - Fork 695
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
Allow defining node properties on template #382
Conversation
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.
Seems like a reasonable feature. Some small code change suggestions. I don't think it's a great idea to make any public fields that aren't trivial properties, and since you've made a lazily initialized field, this should be private for sure.
Thanks for the quick review! I swear I had made that field private... Both changes committed and tested. |
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.
Changes look good, though I haven't tested this manually.
Retrigger-CI |
Code re-rebased; conflicts solved again; tested. |
@mildsunrise @res0nance Does this resolve https://issues.jenkins-ci.org/browse/JENKINS-36544? The merge commit shows it is included in tags: I'm running v1.49.1, but I do not see the Node Properties option where it looks like it should be. Am I missing something? |
I see the Node Properties listed if I click Configure on a slave instance that was already launched. But I assumed this should appear in the "Configure Clouds" template -- and I don't see it in that template. |
That's strange, I'm running v1.49.1 and I do see the node properties section at the bottom of the AMI definition in the advanced properties 🤔 |
OK, that worries me then 😶 I also tried editing I don't think it should matter, but I am using a spot instance template. I'm at the extent of my knowledge here, but it seems to be something to do with how stapler is generating the form, but I don't know why or how to figure out why. Jenkins v2.219 |
@mildsunrise Any other suggestions that we can look for, to figure out why the Node Properties isn't appearing on my cloud configuration? I added a screenshot to the JENKINS-36544 ticket to show what I see: |
@jhansche Nope, sorry :( I don't know how to debug those problems... the only thing I could suggest is to build this plugin from source and install it. You could make changes to the template and verify that they appear in the UI. |
Thanks for the suggestion. I ran the plugin locally, with the existing POM configuration, which uses jenkins version 2.150.1 by default. On that version of Jenkins, the "Configure Clouds" is still in the System Configuration ($JENKINS/configure) page, instead of the newer separate page. On that old page, I do see the Node Properties descriptor list. Updating the jenkins version to 2.223 (and fixing a dependency version error with @mildsunrise What version of Jenkins are you running, such that you see it working properly? |
The Configure Clouds section got moved to its own page as of jenkinsci/jenkins#4339 with commit 77f1242 on Nov 16. I confirmed that if I run the plugin against version 2.204, it works correctly and I see the Node Properties list. Running against version 2.205 breaks it, and the Node Properties do not appear in the separate Configure Clouds screen. Looks like this PR got approved on Nov 2, but didn't merge until a month later on Dec 1, after the Configure Clouds change happened. Is it possible that this change assumed it was going to be in the /configure Configure System screen, and after that moves to its own screen, it no longer has access to those Node Properties for some reason? |
Tracked this down further by debugging the config.jelly file:
In version 2.204 and older, Looking into https://wiki.jenkins.io/display/JENKINS/Basic+guide+to+Jelly+usage+in+Jenkins#BasicguidetoJellyusageinJenkins-Otherpredefinedobjects I see that
causes it to work properly on both older and newer Jenkins versions. I will open a new PR with this fix. |
Wow, great work :o Yeah, that explains it... Thanks a lot! |
This is a follow-up fix for PR jenkinsci#382. In 2.204, the "Configure Clouds" screen was on the main /configure system configuration page. As a result, `${it}` referred to the global system object, aka the Hudson instance. In 2.205, PR jenkinsci/jenkins#4339 merged, which moves the Configure Clouds section to a new page: /configureClouds. As a result of that change, `${it}` no longer refers to the Hudson instance, but to a new GlobalCloudConfiguration object. That object does not have the `getNodePropertyDescriptors()` method, so it is not able to populate the "Node Properties" block. Switching that to `${app}` gives it a correct reference to the Hudson object, and that allows it to show the Node Properties block on all Jenkins versions, both before and after v2.205.
New PR opened: #440 |
* [JENKINS-36544] Fix Node Properties on Jenkins 2.205+ This is a follow-up fix for PR #382. In 2.204, the "Configure Clouds" screen was on the main /configure system configuration page. As a result, `${it}` referred to the global system object, aka the Hudson instance. In 2.205, PR jenkinsci/jenkins#4339 merged, which moves the Configure Clouds section to a new page: /configureClouds. As a result of that change, `${it}` no longer refers to the Hudson instance, but to a new GlobalCloudConfiguration object. That object does not have the `getNodePropertyDescriptors()` method, so it is not able to populate the "Node Properties" block. Switching that to `${app}` gives it a correct reference to the Hudson object, and that allows it to show the Node Properties block on all Jenkins versions, both before and after v2.205. * Use the correct form of getNodePropertyDescriptors() Current master is calling `${it.getNodePropertyDescriptors()}`, but on Jenkins versions <= 2.204, that is calling the method on the global Jenkins node (via Node class). It should instead be using the version of the method that was added in SlaveTemplate, and to do that from a Jelly script, it needs to be moved into the SlaveTemplate.DescriptorImpl class.
Proposal to allow defining node properties (environment variables, tool locations, etc.) that will be applied to created slaves.
EC2AbstractSlave
and children already take anodeProperties
parameter, so we just need to add the field toSlaveTemplate
.