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

Ensure allocDir is never nil and persisted safely #2838

Merged
merged 5 commits into from
Jul 18, 2017
Merged

Conversation

schmichael
Copy link
Member

@schmichael schmichael commented Jul 14, 2017

Fixes #2834

Sorry for the PR noise by adding the AllocRunner.allocID field. It was part of a larger effort I mostly abandoned but wanted to keep that bit.

@schmichael schmichael changed the title Ensure allocDir is never nil and persisted safely WIP: Ensure allocDir is never nil and persisted safely Jul 14, 2017
}
// Build allocation directory (idempotent)
if err := r.allocDir.Build(); err != nil {
r.logger.Printf("[WARN] client: failed to build task directories: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't it [ERROR]?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup! Thanks. Fixing.

@schmichael schmichael changed the title WIP: Ensure allocDir is never nil and persisted safely Ensure allocDir is never nil and persisted safely Jul 17, 2017
@schmichael schmichael requested a review from dadgar July 17, 2017 22:08
Task dir metadata is created in AllocRunner.Run which may not run before
an alloc is sync'd and Nomad exits. There's no reason not to just create
task dir metadata on restore if it doesn't exist.
Since the AllocRunner.alloc struct can be mutated, most of AllocRunner
needs to acquire a lock to get the alloc's ID. Log lines always need to
include the alloc ID, so we often skipped acquiring a lock just to grab
the ID and accepted the race.

Let's make the race detector a little happier by storing the ID in a
single assignment field.
@schmichael schmichael merged commit ed4d265 into master Jul 18, 2017
@schmichael schmichael deleted the b-alloc-dir-fixes branch July 18, 2017 17:19
@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 Mar 28, 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