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

fix: job canonicalization should set job priority to 50, not 0. #17314

Merged
merged 2 commits into from
May 30, 2023

Conversation

pkazmierczak
Copy link
Contributor

@pkazmierczak pkazmierczak commented May 25, 2023

Nomad API will reject jobs with priority set to 0.

        	* Job priority must be between [1, 100])

@pkazmierczak pkazmierczak marked this pull request as ready for review May 25, 2023 16:29
@pkazmierczak pkazmierczak requested review from shoenig and tgross May 25, 2023 16:29
@pkazmierczak pkazmierczak self-assigned this May 25, 2023
@pkazmierczak pkazmierczak added backport/1.3.x backport to 1.3.x release line backport/1.4.x backport to 1.4.x release line backport/1.5.x backport to 1.5.x release line labels May 25, 2023
@pkazmierczak
Copy link
Contributor Author

I see the problem in

t.Fatalf("job didn't get defaulted")
but I don't understand the logic of the test. Line 331 resets job priority, so how come we expect it to remain 50? And how does my change affect it?

Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pkazmierczak this looks right at first in terms of the canonicalization but in the Job.Register RPC we set the priority to the default priority (50) if the priority is 0. So this would break that and make it so that jobs with unset priority are set to 1 instead of 50.

ref https://github.com/hashicorp/nomad/blob/v1.5.5/nomad/job_endpoint.go#L866-L869

@pkazmierczak
Copy link
Contributor Author

oof missed that part, thanks for clarifying @tgross
I fixed in 584fd47, does it make more sense now?

@pkazmierczak pkazmierczak changed the title fix: job canonicalization should set job priority to 1, not 0. fix: job canonicalization should set job priority to 50, not 0. May 25, 2023
api/jobs.go Outdated
@@ -1003,7 +1003,7 @@ func (j *Job) Canonicalize() {
j.Namespace = pointerOf(DefaultNamespace)
}
if j.Priority == nil {
j.Priority = pointerOf(0)
j.Priority = pointerOf(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we claim the default is 50 - should that be the value set here?

https://developer.hashicorp.com/nomad/docs/job-specification/job#priority

edit: dangit, forgot to hit submit

Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.3.x backport to 1.3.x release line backport/1.4.x backport to 1.4.x release line backport/1.5.x backport to 1.5.x release line
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants