Skip to content
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

Exec UI failing when job.ID != job.Name #7814

Closed
PouuleT opened this issue Apr 27, 2020 · 3 comments · Fixed by #7815
Closed

Exec UI failing when job.ID != job.Name #7814

PouuleT opened this issue Apr 27, 2020 · 3 comments · Fixed by #7815
Assignees

Comments

@PouuleT
Copy link
Contributor

PouuleT commented Apr 27, 2020

Nomad version

Output from nomad version

Nomad v0.11.1

Operating system and Environment details

Debian buster

Issue

I am running a job:
ID: f5e3edd3-deeb-46ed-a4d4-2852c3a7a5bd
Name: w000t.f5e3edd3-deeb-46ed-a4d4-2852c3a7a5bd

When trying to use the new Exec feature from the UI, I get on the job view:
https://server/ui/jobs/f5e3edd3-deeb-46ed-a4d4-2852c3a7a5bd

When I click on "Exec", a pop up opens with this:
nomad-not-found
URL of the popup :
https://server/ui/exec/w000t.f5e3edd3-deeb-46ed-a4d4-2852c3a7a5bd

If I manually change the URL to https://server/ui/exec/f5e3edd3-deeb-46ed-a4d4-2852c3a7a5bd , everything runs correctly, the Exec page is loaded and working

Reproduction steps

Create a Job with an ID that is not the same as the Name ( I do it with the golang library using this method )
Go to the web UI, try to "Exec" in the job, you'll see that the UI is trying to load the job by its name rather than its ID

Nomad Server logs

Apr 27 17:16:44 host-1 nomad[2782]:     2020-04-27T17:16:44.968+0200 [ERROR] http: request failed: method=GET path=/v1/job/w000t.f5e3edd3-deeb-46ed-a4d4-2852c3a7a5bd error="job not found" code=404
@backspace
Copy link
Contributor

Thanks for letting us know about this, I should be able to check it out this week. 💞

@PouuleT
Copy link
Contributor Author

PouuleT commented Apr 27, 2020

I couldn't find a place in the doc explaining the difference between Name and ID, so when implementing a new Job with the api.NewServiceJob method, I thought I'd use a UUID as the ID, and something more meaningful like service_type.UUID, and everything was working fine so it was great, until now!

When digging into the code while trying to understand the issue, I noticed that in many places, job ID is substituted by job Name.

In the API for example, sometimes the variable is called jobName

return s.jobSummaryRequest(resp, req, jobName)

While in reality it is used as an ID
JobID: name,

In the UI, take a job_name parameter

this.route('job', { path: '/:job_name' }, function() {

And rename it to ID in order to find the object
const fullId = JSON.stringify([name, namespace || 'default']);

In the tests of the API, the mock Job has an ID != Name so everything is working and tested as it should be
On the UI side however, I saw that the "mock" job has the ID = Name

name() {
return this.id;
},

Indeed, if you change the id to something different than the name, you'll notice that the tests for the "Exec" UI ( and some others ) will fail

So I don't know how to handle this issue, I began working on a fix for the Exec, and then I saw that the job.Name vs job.ID swap is bigger than just the Exec feature.
Is it worth trying to rename jobName to jobID ( when the name is not matching the reality ) in the whole codebase?

backspace added a commit that referenced this issue Apr 27, 2020
This closes #7814. It’s not testable within the current
testing structure, unfortunately.
backspace added a commit that referenced this issue Apr 27, 2020
This closes #7814. It’s not testable within the current
testing structure, unfortunately.
backspace added a commit that referenced this issue Apr 29, 2020
This closes #7814. It makes URL-generation more central and changes
the exec URL to include job id instead of name.
@github-actions
Copy link

github-actions bot commented Nov 8, 2022

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants