Unable to submit (JSON) jobs via the Nomad CLI or the HTTP API

765 views
Skip to first unread message

Tarpan pathak

unread,
Jul 6, 2016, 2:35:13 PM7/6/16
to Nomad
Hi,
We are unable to submit any Nomad jobs using JSON but HCL/Nomad jobs work as expected. Here are some of our attempts unsuccessful attempts: 

- nomad run -address=http://<ipaddr_of_master> -verbose job.json
Error parsing job file job.json: 1 error(s) occurred:

* invalid key: Job 

- curl -vX POST http://<ipaddr_of_master>/v1/jobs -d @job.json
*   Trying...
* Connected to "master" (ipaddr_of_master) port 4646 (#0)
> POST /v1/jobs HTTP/1.1
> Host: xx.xx.xx.xx:4646
> User-Agent: curl/7.43.0
> Accept: */*
> Content-Length: 36998
> Content-Type: application/x-www-form-urlencoded
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
* We are completely uploaded and fine
< HTTP/1.1 500 Internal Server Error
< Date: Wed, 06 Jul 2016 18:30:52 GMT
< Content-Length: 173
< Content-Type: text/plain; charset=utf-8
<
1 error(s) occurred:

* Task group 1 validation failed: 1 error(s) occurred:

* Task 1 validation failed: 2 error(s) occurred:

* Missing task resources
* Connection #0 to host xx.xx.xx.xx left intact


- Couple of notes that might help reproduce this issue: 
Nomad version: v0.3.2 

JSON file validates successfully (confirmed using jsonlint)

nomad validate jobRhozet.json
Error parsing job file jobRhozet.json: 1 error(s) occurred:

* invalid key: Job


Please point me in the right direction on how to successfully submit (JSON) jobs and let me know if you have any questions. 

Diptanu Choudhury

unread,
Jul 6, 2016, 9:20:54 PM7/6/16
to Tarpan pathak, Nomad
Hi Tarpan,

The nomad run cli command works only with HCL files. If you want to submit jobs using json, please use the HTTP APIs[1].




--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/nomad/issues
IRC: #nomad-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Nomad" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nomad-tool+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nomad-tool/25ae2c37-865d-4d85-a27d-154a60a4744d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Thanks,
Diptanu Choudhury

Gmail

unread,
Jul 6, 2016, 9:24:34 PM7/6/16
to Diptanu Choudhury, Nomad
Hi Diptanu, 
Thanks for confirming. I tried submitting a job using the HTTP API but get a (file) validation error. Let me spend some time to review the job definition. 

Cheers,
Tarpan


Tarpan pathak

unread,
Jul 7, 2016, 3:56:46 PM7/7/16
to Nomad
Hello again,
I am now able to submit (JSON) files/jobs using the HTTP API. The cause of the failed jobs was due to the lack of (task) Resources and LogConfigs. Now, Nomad is unable to run the job and produces one of the following errors: 

exec: "C:\\...................\\<full_path_to_binary>": file does not exist. 

OR 

fork/exec C:<full_path_to_binary>: The filename or extension is too long.  

Once again, I am running Nomad version 0.3.2. Could you point me in the right direction as to why this error is being thrown?  

Diptanu Choudhury

unread,
Jul 7, 2016, 7:02:18 PM7/7/16
to Tarpan pathak, Nomad
Hi Tarpan,

Nomad is not able to find the binary in the specified path. Can you verify it's present in that path on the node where the Nomad client is running?

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/nomad/issues
IRC: #nomad-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Nomad" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nomad-tool+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Gmail

unread,
Jul 7, 2016, 7:11:45 PM7/7/16
to Diptanu Choudhury, Nomad
Hi Diptanu,
Yes, I have already confirmed that the binary exists by opening a Powershell window and successfully executing it (using program_name.exe). If I can recall correctly, we were able to successful schedule and run jobs using HCL but now have a need to migrate to JSON. Note: these jobs are being scheduled on a Windows Server 2008 R2 instance using the “raw_exec” driver. 

I continue reviewing docs/articles to find a cause for this issue. Let me know if I can provide further details to help you better understand this problem.  

Cheers,
Tarpan


Alex Dadgar

unread,
Jul 11, 2016, 1:52:10 PM7/11/16
to Gmail, Diptanu Choudhury, Nomad
Hmm I was able to run a raw_exec job with the absolute path. If you were able to run via HCL, then it is most likely a config problem. I would just run `nomad run -output working.hcl`. This will produce an equivalent version in JSON.

Thanks,
Alex

Gmail

unread,
Jul 11, 2016, 2:31:23 PM7/11/16
to Alex Dadgar, Diptanu Choudhury, Nomad
Understood, thanks Alex. I will try HCL instead.  

Question: Because we are using JSON, can nomad unmarshal a specified file to HCL? I ask because I am trying to avoid manually creating HCL files since we have the equivalent JSON config. 

Cheers,
Tarpan


Alex Dadgar

unread,
Jul 11, 2016, 2:53:07 PM7/11/16
to Gmail, Diptanu Choudhury, Nomad
Hey,

We do not have the ability to go back to the HCL version. It is not always a one to one mapping as we do some things in the HCL parser to make things simpler.

Thanks,
Alex

Gmail

unread,
Jul 11, 2016, 3:04:56 PM7/11/16
to Alex Dadgar, Diptanu Choudhury, Nomad
Hey Alex,
Got it, thanks again. 

I (manually) created the HCL file, ran “nomad run file.hcl”. The file gets scheduled and runs successfully. There is still an issue with Nomad finding the absolute path to the binary on the worker. 

FYI, I am currently wrapping up the artifact config but once completed I can go back to the absolute/relative path config for the Windows raw_exec driver. If and when successful, I will notify you so you are in the loop. 

Cheers,
Tarpan


Alex Dadgar

unread,
Jul 11, 2016, 5:06:11 PM7/11/16
to Gmail, Diptanu Choudhury, Nomad
Thanks,

Hmm that is odd, when you do, please include the stderr and executor logs as well as the client. I just did it on 0.4 and it worked on Windows 8 I believe.

- Alex Dadgar
Reply all
Reply to author
Forward
0 new messages