Nomad: File in use error when validating job on windows

Created on 16 Sep 2016  路  17Comments  路  Source: hashicorp/nomad

If you have a question, prepend your issue with [question] or preferably use the nomad mailing list.

If filing a bug please include the following:

Nomad version

Nomad v0.4.1

Operating system and Environment details

Windows 7 64-bit

Issue

When validating a job file with nomad validate <job_file> I receive the error
Error getting job struct: Error getting jobfile from "example.nomad": remove C:\Users\user\AppData\Local\Temp\jobfile382992987: The process cannot access the file because it is being used by another process.

This works with Nomad 0.4.0

Reproduction steps

1 nomad init
2 nomad validate example.nomad

Nomad Server logs (if appropriate)

I'm not running this as a client or server. Just using it to validate job files

themcli themplatform-windows typbug

Most helpful comment

Small workaround I think about, is to use 'nomad run - < file.nomad', but yes, that's only prove that I don't need extra privilege to run the job, only to create the symlink.

All 17 comments

I think it's the same problem as in https://github.com/hashicorp/nomad/pull/1690
Can you build from master and check?

Going to close this as it has been quite a while and the same fix @mwieczorek references should fix this too. Feel free to reopen if you are still affected by this.

Thank,
Alex

Sorry it took so long but I have never setup a go environment. I have everything setup used go get github.com/hashicorp/nomad. in the bin directory I now have a nomad.exe that reports version v0.5.0-rc2. When I run nomad I'm using the full path to the executable located in the bin folder.

I type nomad init then nomad validate example.nomad and I recive the following error:
Error getting job struct: Error getting jobfile from "example.nomad": symlink C:\Users\username\go_workspace\example.nomad C:\Users\username\AppData\Local\Temp\jobfile616974243: A required privilege is not held by the client.

I have tried locating the example.nomad file in various directories that I know I have write permission to. This does work if I run from an elevated command prompt.

@wstaples I am assuming same error for nomad run example.nomad? Re-opening.

@mwieczorek Any ideas as to the cause?

@wstaples What version of Windows?

Windows 7 64-bit. Yes I receive the same error running nomad run example.nomad

@dadgar Looks like nomad cannot create symlink
I checked 0.5RC2 on Windows 10 and everything is working ok.

A required privilege is not held by the client

Quick search and I found this:
http://stackoverflow.com/questions/23217460/how-to-create-soft-symbolic-link-using-java-nio-files

@wstaples Can you try that solution?

Hi, where can I get windows 64bit binary 0.5RC2 ? Regards. Qba.

Thx. Dzi臋kuj臋.

@mwieczorek

Unfortunately this did not work.

This may work for a windows limited user account but it will not work for users in the 'administrator' group. As you can see here: http://superuser.com/a/376141. I tried adding my user to the list anyway and restarted but no luck. Using run as which was suggested in the superuser thread would require a user to enter their password or have the guest account enabled neither of which I would recommend. So it seems like nomad would have to test if the user is a member of the administrators group and if so elevate the session.

@wstaples maybe it's something related to win7. if I find time I'll try to build box (https://github.com/joefitzgerald/packer-windows/blob/master/windows_7.json) and test it.

I confirm is a general condition on using symlink on Windows. I have the same problem with Windows 10, and the worse part is that you cannot get this privilege if you're using Home Edition, where the only thing you can do is to always run with Elevated privileges.

Given that only nomad can accept job written in HCL, it will be a big change to my workflow if I need to transform all my templates to JSON and only used the http api for submitting. Could we get nomad accept a "copy" option to pass to go-getter or, even better, have go-getter handle this more gracefully by default? Right now, that's my only roadbloack to use all the wonderful stuff of 0.5.

Small workaround I think about, is to use 'nomad run - < file.nomad', but yes, that's only prove that I don't need extra privilege to run the job, only to create the symlink.

or, even better, have go-getter handle this more gracefully by default?
@ninoles So maybe it should be an issue in go-getter?

closing this in favor of #3491

Was this page helpful?
0 / 5 - 0 ratings