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

Job revert #2575

Merged
merged 8 commits into from
Apr 27, 2017
Merged

Job revert #2575

merged 8 commits into from
Apr 27, 2017

Conversation

dadgar
Copy link
Contributor

@dadgar dadgar commented Apr 19, 2017

This PR introduces a revert endpoint that allows a job to be reverted to a prior state.

@dadgar dadgar requested review from schmichael and armon April 19, 2017 22:57
Copy link
Member

@schmichael schmichael left a comment

Choose a reason for hiding this comment

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

LGTM with one minor comment nit

return fmt.Errorf("job %q not found", args.JobID)
}

if args.JobVersion == cur.Version {
Copy link
Member

Choose a reason for hiding this comment

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

Make sure JobByID's docs explain it returns the "latest" or "current" version of a Job ID now that an ID doesn't uniquely identify exactly one *structs.Job.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call! Done.


// If the request is enforcing the existing version do a check.
if args.EnforcePriorVersion != nil {
if cur.Version != *args.EnforcePriorVersion {
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 racy, and probably should be evaluated inside the FSM. Effectively this is a check-and-set, but multiple concurrent calls to this API will be allowed to make progress depending on the timing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I realized that when implementing this. The register endpoint should push the logic from the RPC layer down into the FSM. This will fix this issue for both this and the register. Just out of scope for this PR. I will put a comment on that part of the code though

return fmt.Errorf("job %q at version %d not found", args.JobID, args.JobVersion)
}

cur, err := snap.JobByID(ws, args.JobID)
Copy link
Member

Choose a reason for hiding this comment

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

I would check this first, since you expect to get the "job not found" error before the "job at version" not found error.

}

reg.EnforceIndex = true
reg.JobModifyIndex = cur.JobModifyIndex
Copy link
Member

Choose a reason for hiding this comment

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

The modify index will get overwritten at Upsert time right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those two are the way to do the CAS operation on the register

@dadgar dadgar merged commit 404626c into master Apr 27, 2017
@dadgar dadgar deleted the f-job-revert branch April 27, 2017 17:54
@github-actions
Copy link

github-actions bot commented Apr 2, 2023

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 Apr 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants