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

server: handle invalid jobs in expose handler hook #10154

Merged
merged 2 commits into from
Mar 10, 2021
Merged

server: handle invalid jobs in expose handler hook #10154

merged 2 commits into from
Mar 10, 2021

Conversation

notnoop
Copy link
Contributor

@notnoop notnoop commented Mar 9, 2021

The expose handler hook must handle if the submitted job is invalid. Without this validation, the rpc handler panics on invalid input.

Fixes #10115

The expose handler hook must handle if the submitted job is invalid.
Comment on lines +43 to +44
// Mutators run first before validators, so validators view the final rendered job.
// So, mutators must handle invalid jobs.
Copy link
Contributor Author

@notnoop notnoop Mar 9, 2021

Choose a reason for hiding this comment

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

I'm not fully sure what the motivation of having mutators run first: but this has bitten us before with a similar panic #6575 .

I'm not fully sure of the impact of re-ordering steps, so we validate first then mutate. Skimming code, that would mean that we'd attempt to validating the job first before canonalizing it, which may open another can of worms.

Copy link
Member

Choose a reason for hiding this comment

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

This is really unfortunate in that we really have two types of validation: validation for safety which really wants to happen before mutation (canonicalization, making sure we don't have nil pointers in unexpected places), and validation for "business logic" (ex. task group count for system jobs).

But solving that is beyond the scope of this bug fix, so 👍 for leaving this comment.

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

Comment on lines +43 to +44
// Mutators run first before validators, so validators view the final rendered job.
// So, mutators must handle invalid jobs.
Copy link
Member

Choose a reason for hiding this comment

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

This is really unfortunate in that we really have two types of validation: validation for safety which really wants to happen before mutation (canonicalization, making sure we don't have nil pointers in unexpected places), and validation for "business logic" (ex. task group count for system jobs).

But solving that is beyond the scope of this bug fix, so 👍 for leaving this comment.

nomad/job_endpoint_test.go Outdated Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview – nomad March 10, 2021 14:12 Inactive
@notnoop notnoop merged commit b0ca1fd into main Mar 10, 2021
@notnoop notnoop deleted the b-gh-10115 branch March 10, 2021 14:12
schmichael pushed a commit that referenced this pull request May 14, 2021
The expose handler hook must handle if the submitted job is invalid. Without this validation, the rpc handler panics on invalid input.

Co-authored-by: Tim Gross <[email protected]>
@tgross tgross added this to the 1.1.0 milestone May 17, 2021
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, 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 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Client panic when submitting a job with exposed service check and no sidecar_service stanza
2 participants