-
Notifications
You must be signed in to change notification settings - Fork 41
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
replace worker template by a more flexible approach #82
replace worker template by a more flexible approach #82
Conversation
03fd9fa
to
e8c2f8b
Compare
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.
added tests for previous migrations
Request.Builder builder = new Request.Builder() | ||
.url(this.nomadApi + "/v1/job/" + workerName + "?region=" + template.getRegion()); | ||
.url(this.nomadApi + "/v1/jobs"); |
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.
Since region
and workerName
are part of the job file already, we don't have to define them here explicitly.
8e94acd
to
e0d8cad
Compare
Anything more to work on here @j3t? I'd love to try and add another worker driver support but would hate to interfere with whatever is happening here. |
@mikedld It's only waiting for my review but I didn't have time to get into this PR and test it yet :'( |
Hi @mikedld, it would be really nice if you could test the current state and give use feedback.You can find the build artifacts here https://ci.jenkins.io/blue/organizations/jenkins/Plugins%2Fnomad-plugin/detail/PR-82/10/artifacts. You just have to download the hpi file and then you can install it manually via |
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.
@j3t I (finally!) took a bit of time to have a look at your pull request.
Generally speaking: it's quite cool 🎉
I had a look if we could have native Nomad jobs (HCL) instead of JSON as it would be easier to write in the text area, and it would provide native support for interpolating the secret/token variables if it was supporting HCL2 but:
- The only HCL capable Java library I found was https://github.com/bertramdev/hcl4j and it doesn't support HCL2 for the time being.
- Migrating from the original configuration to HCL may be more challenging (in the past, I found it difficult to serialize arbitrary structure to HCL, I don't it has changed since)
Anyway:
I think it would be useful to add loggers from the migrations are executed, I would say:
- At the very least when a worker template is migrated
- Possibly when the whole migration is executed
Otherwise, from what I have tested, this is working great and I don't see any problem merging this soon 👍
src/main/resources/org/jenkinsci/plugins/nomad/NomadWorkerTemplate/help-jobTemplate.html
Outdated
Show resolved
Hide resolved
e0d8cad
to
2a8fa1b
Compare
7952cb1
to
1a610a0
Compare
Thanks! I have incorporated the feedback. What is about the SpotBugs findings (UUF_UNUSED_FIELD)? I don't know how this could be solved? Is there a way to ignore them? |
In general I would like to have that but as far as I know, the Nomad REST API only supports JSON. This means we have to transform HCL2 to JSON, right? There is a discussion and also some libraries available (see hashicorp/hcl#294). |
Co-authored-by: Jonathan Ballet <jon@multani.info>
Maybe we can use the Nomad API to transform HCL to JSON (see https://www.nomadproject.io/api-docs/jobs#parse-job). |
The API only takes JSON yes, but if it could be transformed once before submitting the job, that would be really nice! Also (I forgot yesterday), in any case, it would be nice if the UI could provide some basic validation of the input: at the moment, writing in a non-valid JSON "succeeds" silently when the form is submitted :) |
Do we really need the HCL support in the first place? I mean, we could add it later as an alternative as well. |
We could use the Nomad API for that as well (see https://www.nomadproject.io/api-docs/validate#validate-job), but I prefer a validation button for that instead of a silent validation when the form is submitted. |
If there's a good UX / migration path for supporting HCL later, it's fine by me 👍 (I don't really see how to nicely support both right now though).
The validation button would be fine, yes 👍 Actually, I haven't tried to save the buggy JSON and see what the plugin would do in that case; but the earlier and clearer the error message we can get, the better it would be IMO. From experience, when cloud workers provisioning fails for any reason (the Nomad plugin or any other plugin providing dynamic workers), it's always a PITA to debug / figure out in Jenkins. |
4415e57
to
a983949
Compare
a983949
to
2540039
Compare
We could just allow both formats. No migration necessary at all. |
Yes, that's great!
OK, well let's start with this initial approach and think how to add (or not) HCL after that. |
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.
Tested with the latest changes and looks good to me!
@j3t Thanks a lot for this refactoring: this is a huge PR and I think it will help to support more Nomad features/changes in the future, this is really cool 🚀 |
I directly released a new version in https://github.com/jenkinsci/nomad-plugin/releases/tag/v0.9.0 |
I have created different plugin configuration based on v0.7.4 and added tests for them (see
NomadCloudConfigurationTest
). Afterwards, I have replaced the worker template by a more flexible approach and added a migration path for older configurations.