-
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
fix: remove job using namespace #139
Conversation
Jobs created in other namespace than `default` are not removed correctly when worker is stopped. Provide the namespace to the nomad api when removing a Job/stopping a worker.
62fc7e6
to
0c2cc15
Compare
We've encountered this as well, and a related problem with nomad regions, where the job template can cause an agent to be run in a non-default region, but the request to destroy the agent does not specify the region and fails. Do you think this PR could be extended to handle region as well? |
4a3c0d3
to
d67391d
Compare
I have added the region to the DELETE when it is not global/default region. The change doesn't handle multi region, not sure it is an actual use case for anyone. |
Jobs created in other region than `global` are not removed when worker is stopped. This fix doesn't handle multi region yet.
d67391d
to
32f810c
Compare
Make sure we leave enough time for a new nomad worker to join the jenkins controller before removing the nomad worker.
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 didn't tested the fix related to the region (I don't have the setup to test that under my hands), but looking at the code this looks good. Thanks for the fix! 🙇
String workerJob = nomad.startWorker(workerName, jnlpSecret, template); | ||
JSONObject workerJobJSON = new JSONObject(workerJob).getJSONObject("Job"); | ||
String namespace = workerJobJSON.optString("Namespace"); | ||
if (!namespace.equals("")) { | ||
worker.setNamespace(namespace); | ||
} | ||
worker.setRegion(workerJobJSON.optString("Region")); |
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.
Maybe we should have a way to represent jobs as an objects, and serialize them on demand before sending them to the API, instead of building strings and parsing them out again from JSON to get/change some values.
I'll release it as part of 0.9.3, but https://repo.jenkins-ci.org is down at the moment. |
Jobs created in other namespace than
default
are not removed correctlywhen worker is stopped.
Provide the namespace to the nomad api when removing a Job/stopping a
worker.