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 'nomad run' on windows #1690

Merged
merged 1 commit into from
Sep 5, 2016
Merged

Fix 'nomad run' on windows #1690

merged 1 commit into from
Sep 5, 2016

Conversation

mwieczorek
Copy link
Contributor

@mwieczorek mwieczorek commented Sep 5, 2016

After PR #1511
there is a problem with running job on windows.

If I run sample job:

nomad.exe run .\example.nomad

I get an error:

Error getting job struct: Error getting jobfile from ".\\example.nomad": remove C:\Users\vagrant\AppData\Local\Temp\jobfile806333599: The process cannot access the file because it is being used by another process.

It's because ioutil.TempFile "opens the file for reading and writing" (docs).
And go-getter is trying to delete this file and create new.
Closing the file will let windows to delete the file without the error above.

@mwieczorek mwieczorek changed the title Close job temp file Fix 'nomad run' on windows Sep 5, 2016
@@ -255,6 +255,11 @@ func (j *JobGetter) StructJob(jpath string) (*structs.Job, error) {
}
defer os.Remove(job.Name())

err = job.Close()
Copy link
Contributor

Choose a reason for hiding this comment

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

if err := job.Close(); err != nil

@diptanu
Copy link
Contributor

diptanu commented Sep 5, 2016

@mwieczorek Left a small comment.

@mwieczorek
Copy link
Contributor Author

@diptanu Corrected.

@diptanu
Copy link
Contributor

diptanu commented Sep 5, 2016

@mwieczorek Thanks!

@diptanu diptanu merged commit 79faa8c into hashicorp:master Sep 5, 2016
@mwieczorek mwieczorek deleted the fix-nomad-run-on-windows branch September 5, 2016 21:47
@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 Apr 17, 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.

2 participants