github.com/diptanu/nomad@v0.5.7-0.20170516172507-d72e86cbe3d9/website/source/docs/http/job.html.md (about)

     1  ---
     2  layout: "http"
     3  page_title: "HTTP API: /v1/job"
     4  sidebar_current: "docs-http-job-"
     5  description: |-
     6    The '/1/job' endpoint is used for CRUD on a single job.
     7  ---
     8  
     9  # /v1/job
    10  
    11  The `job` endpoint is used for CRUD on a single job. By default, the agent's local
    12  region is used; another region can be specified using the `?region=` query parameter.
    13  
    14  ## GET
    15  
    16  <dl>
    17    <dt>Description</dt>
    18    <dd>
    19      Query a single job for its specification and status.
    20    </dd>
    21  
    22    <dt>Method</dt>
    23    <dd>GET</dd>
    24  
    25    <dt>URL</dt>
    26    <dd>`/v1/job/<ID>`</dd>
    27  
    28    <dt>Parameters</dt>
    29    <dd>
    30      None
    31    </dd>
    32  
    33    <dt>Blocking Queries</dt>
    34    <dd>
    35      [Supported](/docs/http/index.html#blocking-queries)
    36    </dd>
    37  
    38    <dt>Returns</dt>
    39    <dd>
    40  
    41      ```javascript
    42      {
    43      "Region": "global",
    44      "ID": "binstore-storagelocker",
    45      "Name": "binstore-storagelocker",
    46      "Type": "service",
    47      "Priority": 50,
    48      "AllAtOnce": false,
    49      "Datacenters": [
    50          "us2",
    51          "eu1"
    52      ],
    53      "Constraints": [
    54          {
    55              "LTarget": "${attr.kernel.os}",
    56              "RTarget": "windows",
    57              "Operand": "="
    58          }
    59      ],
    60      "TaskGroups": [
    61          {
    62              "Name": "binsl",
    63              "Count": 5,
    64              "Constraints": [
    65                  {
    66                      "LTarget": "${attr.kernel.os}",
    67                      "RTarget": "linux",
    68                      "Operand": "="
    69                  }
    70              ],
    71              "Tasks": [
    72                  {
    73                      "Name": "binstore",
    74                      "Driver": "docker",
    75                      "Config": {
    76                          "image": "hashicorp/binstore"
    77                      },
    78                      "Constraints": null,
    79                      "Resources": {
    80                          "CPU": 500,
    81                          "MemoryMB": 0,
    82                          "DiskMB": 0,
    83                          "IOPS": 0,
    84                          "Networks": [
    85                              {
    86                                  "Device": "",
    87                                  "CIDR": "",
    88                                  "IP": "",
    89                                  "MBits": 100,
    90                                  "ReservedPorts": null,
    91                                  "DynamicPorts": null
    92                              }
    93                          ]
    94                      },
    95                      "Meta": null
    96                  },
    97                  {
    98                      "Name": "storagelocker",
    99                      "Driver": "java",
   100                      "Config": {
   101                          "image": "hashicorp/storagelocker"
   102                      },
   103                      "Constraints": [
   104                          {
   105                              "LTarget": "${attr.kernel.arch}",
   106                              "RTarget": "amd64",
   107                              "Operand": "="
   108                          }
   109                      ],
   110                      "Resources": {
   111                          "CPU": 500,
   112                          "MemoryMB": 0,
   113                          "DiskMB": 0,
   114                          "IOPS": 0,
   115                          "Networks": null
   116                      },
   117                      "Meta": null
   118                  }
   119              ],
   120              "Meta": {
   121                  "elb_checks": "3",
   122                  "elb_interval": "10",
   123                  "elb_mode": "tcp"
   124              }
   125          }
   126      ],
   127      "Update": {
   128          "Stagger": 0,
   129          "MaxParallel": 0
   130      },
   131      "Meta": {
   132          "foo": "bar"
   133      },
   134      "Status": "",
   135      "StatusDescription": "",
   136      "Version": 3,
   137      "CreateIndex": 14,
   138      "ModifyIndex": 14
   139      }
   140      ```
   141    </dd>
   142  </dl>
   143  
   144  <dl>
   145    <dt>Description</dt>
   146    <dd>
   147      Query all versions of a single job.
   148    </dd>
   149  
   150    <dt>Method</dt>
   151    <dd>GET</dd>
   152  
   153    <dt>URL</dt>
   154    <dd>`/v1/job/<ID>/versions`</dd>
   155  
   156    <dt>Parameters</dt>
   157    <dd>
   158      None
   159    </dd>
   160  
   161    <dt>Blocking Queries</dt>
   162    <dd>
   163      [Supported](/docs/http/index.html#blocking-queries)
   164    </dd>
   165  
   166    <dt>Returns</dt>
   167    <dd>
   168  
   169      ```javascript
   170      [
   171          {
   172              "Region": "global",
   173              "ID": "binstore-storagelocker",
   174              "Version": 2,
   175              ...
   176          },
   177          {
   178              "Region": "global",
   179              "ID": "binstore-storagelocker",
   180              "Version": 1,
   181              ...
   182          },
   183          {
   184              "Region": "global",
   185              "ID": "binstore-storagelocker",
   186              "Version": 0,
   187              ...
   188          }
   189      ]
   190      ```
   191    </dd>
   192  </dl>
   193  
   194  <dl>
   195    <dt>Description</dt>
   196    <dd>
   197      Query the allocations belonging to a single job.
   198    </dd>
   199  
   200    <dt>Method</dt>
   201    <dd>GET</dd>
   202  
   203    <dt>URL</dt>
   204    <dd>`/v1/job/<ID>/allocations`</dd>
   205  
   206    <dt>Parameters</dt>
   207    <dd>
   208      <ul>
   209        <li>
   210          <span class="param">all</span>
   211          <span class="param-flags">optional</span>
   212          Returns all allocations of job with the given ID including those from
   213          past instances of the job.
   214        </li>
   215      </ul>
   216    </dd>
   217  
   218    <dt>Blocking Queries</dt>
   219    <dd>
   220      [Supported](/docs/http/index.html#blocking-queries)
   221    </dd>
   222  
   223    <dt>Returns</dt>
   224    <dd>
   225  
   226      ```javascript
   227      [
   228      {
   229          "ID": "3575ba9d-7a12-0c96-7b28-add168c67984",
   230          "EvalID": "151accaa-1ac6-90fe-d427-313e70ccbb88",
   231          "Name": "binstore-storagelocker.binsl[0]",
   232          "NodeID": "a703c3ca-5ff8-11e5-9213-970ee8879d1b",
   233          "JobID": "binstore-storagelocker",
   234          "TaskGroup": "binsl",
   235          "DesiredStatus": "run",
   236          "DesiredDescription": "",
   237          "ClientStatus": "running",
   238          "ClientDescription": "",
   239          "CreateIndex": 16,
   240          "ModifyIndex": 16
   241      },
   242      ...
   243      ]
   244      ```
   245  
   246    </dd>
   247  </dl>
   248  
   249  <dl>
   250    <dt>Description</dt>
   251    <dd>
   252      Query the evaluations belonging to a single job.
   253    </dd>
   254  
   255    <dt>Method</dt>
   256    <dd>GET</dd>
   257  
   258    <dt>URL</dt>
   259    <dd>`/v1/job/<ID>/evaluations`</dd>
   260  
   261    <dt>Parameters</dt>
   262    <dd>
   263      None
   264    </dd>
   265  
   266    <dt>Blocking Queries</dt>
   267    <dd>
   268      [Supported](/docs/http/index.html#blocking-queries)
   269    </dd>
   270  
   271    <dt>Returns</dt>
   272    <dd>
   273  
   274      ```javascript
   275      [
   276      {
   277          "ID": "151accaa-1ac6-90fe-d427-313e70ccbb88",
   278          "Priority": 50,
   279          "Type": "service",
   280          "TriggeredBy": "job-register",
   281          "JobID": "binstore-storagelocker",
   282          "JobModifyIndex": 14,
   283          "NodeID": "",
   284          "NodeModifyIndex": 0,
   285          "Status": "complete",
   286          "StatusDescription": "",
   287          "Wait": 0,
   288          "NextEval": "",
   289          "PreviousEval": "",
   290          "CreateIndex": 15,
   291          "ModifyIndex": 17
   292      },
   293      ...
   294      ]
   295      ```
   296  
   297    </dd>
   298  </dl>
   299  
   300  <dl>
   301    <dt>Description</dt>
   302    <dd>
   303      Query the summary of a job.
   304    </dd>
   305  
   306    <dt>Method</dt>
   307    <dd>GET</dd>
   308  
   309    <dt>URL</dt>
   310    <dd>`/v1/job/<ID>/summary`</dd>
   311  
   312    <dt>Parameters</dt>
   313    <dd>
   314      None
   315    </dd>
   316  
   317    <dt>Blocking Queries</dt>
   318    <dd>
   319      [Supported](/docs/http/index.html#blocking-queries)
   320    </dd>
   321  
   322    <dt>Returns</dt>
   323    <dd>
   324  
   325      ```javascript
   326      {
   327        "JobID": "example",
   328        "Children": {
   329          "Dead": 0,
   330          "Running": 7,
   331          "Pending": 2
   332        },
   333        "Summary": {
   334          "cache": {
   335            "Queued": 0,
   336            "Complete": 0,
   337            "Failed": 0,
   338            "Running": 1,
   339            "Starting": 0,
   340            "Lost": 0
   341          }
   342        },
   343        "CreateIndex": 6,
   344        "ModifyIndex": 10
   345      }
   346      ```
   347  
   348    </dd>
   349  </dl>
   350  
   351  
   352  ## PUT / POST
   353  
   354  <dl>
   355    <dt>Description</dt>
   356    <dd>
   357      Registers a new job or updates an existing job
   358    </dd>
   359  
   360    <dt>Method</dt>
   361    <dd>PUT or POST</dd>
   362  
   363    <dt>URL</dt>
   364    <dd>`/v1/job/<ID>`</dd>
   365  
   366    <dt>Parameters</dt>
   367    <dd>
   368      <ul>
   369        <li>
   370          <span class="param">Job</span>
   371          <span class="param-flags">required</span>
   372          The JSON definition of the job.
   373        </li>
   374        <li>
   375          <span class="param">EnforceIndex</span>
   376          <span class="param-flags">optional</span>
   377          If EnforceIndex is set the job will only be registered if the passed
   378          JobModifyIndex matches the current job's index. If the index is zero,
   379          the register only occurs if the job is new. This paradigm allows
   380          check-and-set style job updating.
   381        </li>
   382        <li>
   383          <span class="param">JobModifyIndex</span>
   384          <span class="param-flags">optional</span>
   385          The JobModifyIndex to enforce the current job is at.
   386        </li>
   387      </ul>
   388    </dd>
   389  
   390    <dt>Returns</dt>
   391    <dd>
   392  
   393      ```javascript
   394      {
   395      "EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac",
   396      "EvalCreateIndex": 35,
   397      "JobModifyIndex": 34,
   398      }
   399      ```
   400  
   401    </dd>
   402  </dl>
   403  
   404  <dl>
   405    <dt>Description</dt>
   406    <dd>
   407      Dispatch a new instance of a parameterized job.
   408    </dd>
   409  
   410    <dt>Method</dt>
   411    <dd>PUT or POST</dd>
   412  
   413    <dt>URL</dt>
   414    <dd>`/v1/job/<ID>/dispatch`</dd>
   415  
   416    <dt>Parameters</dt>
   417    <dd>
   418      <ul>
   419        <li>
   420          <span class="param">Payload</span>
   421          <span class="param-flags">optional</span>
   422          A `[]byte` array encoded as a base64 string with a maximum size of 16KiB.
   423        </li>
   424        <li>
   425          <span class="param">Meta</span>
   426          <span class="param-flags">optional</span>
   427          A `map[string]string` of metadata keys to their values.
   428        </li>
   429      </ul>
   430    </dd>
   431  
   432    <dt>Returns</dt>
   433    <dd>
   434  
   435      ```javascript
   436      {
   437      "Index": 13,
   438      "JobCreateIndex": 12,
   439      "EvalCreateIndex": 13,
   440      "EvalID": "e5f55fac-bc69-119d-528a-1fc7ade5e02c",
   441      "DispatchedJobID": "example/dispatch-1485408778-81644024"
   442      }
   443      ```
   444  
   445    </dd>
   446  </dl>
   447  
   448  <dl>
   449    <dt>Description</dt>
   450    <dd>
   451      Creates a new evaluation for the given job. This can be used to force
   452      run the scheduling logic if necessary.
   453    </dd>
   454  
   455    <dt>Method</dt>
   456    <dd>PUT or POST</dd>
   457  
   458    <dt>URL</dt>
   459    <dd>`/v1/job/<ID>/evaluate`</dd>
   460  
   461    <dt>Parameters</dt>
   462    <dd>
   463      None
   464    </dd>
   465  
   466    <dt>Returns</dt>
   467    <dd>
   468  
   469      ```javascript
   470      {
   471      "EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac",
   472      "EvalCreateIndex": 35,
   473      "JobModifyIndex": 34,
   474      }
   475      ```
   476  
   477    </dd>
   478  </dl>
   479  
   480  <dl>
   481    <dt>Description</dt>
   482    <dd>
   483      Invoke a dry-run of the scheduler for the job.
   484    </dd>
   485  
   486    <dt>Method</dt>
   487    <dd>PUT or POST</dd>
   488  
   489    <dt>URL</dt>
   490    <dd>`/v1/job/<ID>/plan`</dd>
   491  
   492    <dt>Parameters</dt>
   493    <dd>
   494      <ul>
   495        <li>
   496          <span class="param">Job</span>
   497          <span class="param-flags">required</span>
   498          The JSON definition of the job.
   499        </li>
   500        <li>
   501          <span class="param">Diff</span>
   502          <span class="param-flags">optional</span>
   503          Whether the diff structure between the submitted and server side version
   504          of the job should be included in the response.
   505        </li>
   506      </ul>
   507    </dd>
   508  
   509    <dt>Returns</dt>
   510    <dd>
   511  
   512      ```javascript
   513  	{
   514  	  "Index": 0,
   515  	  "NextPeriodicLaunch": "0001-01-01T00:00:00Z",
   516  	  "Diff": {
   517  		"Type": "Added",
   518  		"TaskGroups": [
   519  		  {
   520  			"Updates": {
   521  			  "create": 1
   522  			},
   523  			"Type": "Added",
   524  			"Tasks": [
   525  			  {
   526  				"Type": "Added",
   527  				"Objects": [...],
   528  				"Name": "redis",
   529  				"Fields": [
   530  				  {
   531  					"Type": "Added",
   532  					"Old": "",
   533  					"New": "docker",
   534  					"Name": "Driver",
   535  					"Annotations": null
   536  				  },
   537  				  {
   538  					"Type": "Added",
   539  					"Old": "",
   540  					"New": "5000000000",
   541  					"Name": "KillTimeout",
   542  					"Annotations": null
   543  				  }
   544  				],
   545  				"Annotations": [
   546  				  "forces create"
   547  				]
   548  			  }
   549  			],
   550  			"Objects": [...],
   551  			"Name": "cache",
   552  			"Fields": [...]
   553  		  }
   554  		],
   555  		"Objects": [
   556  		  {
   557  			"Type": "Added",
   558  			"Objects": null,
   559  			"Name": "Datacenters",
   560  			"Fields": [...]
   561  		  },
   562  		  {
   563  			"Type": "Added",
   564  			"Objects": null,
   565  			"Name": "Constraint",
   566  			"Fields": [...]
   567  		  },
   568  		  {
   569  			"Type": "Added",
   570  			"Objects": null,
   571  			"Name": "Update",
   572  			"Fields": [...]
   573  		  }
   574  		],
   575  		"ID": "example",
   576          "Fields": [...],
   577  		  ...
   578  		]
   579  	  },
   580  	"CreatedEvals": [
   581  		{
   582  		  "ModifyIndex": 0,
   583  		  "CreateIndex": 0,
   584  		  "SnapshotIndex": 0,
   585  		  "AnnotatePlan": false,
   586  		  "EscapedComputedClass": false,
   587  		  "NodeModifyIndex": 0,
   588  		  "NodeID": "",
   589  		  "JobModifyIndex": 0,
   590  		  "JobID": "example",
   591  		  "TriggeredBy": "job-register",
   592  		  "Type": "batch",
   593  		  "Priority": 50,
   594  		  "ID": "312e6a6d-8d01-0daf-9105-14919a66dba3",
   595  		  "Status": "blocked",
   596  		  "StatusDescription": "created to place remaining allocations",
   597  		  "Wait": 0,
   598  		  "NextEval": "",
   599  		  "PreviousEval": "80318ae4-7eda-e570-e59d-bc11df134817",
   600  		  "BlockedEval": "",
   601  		  "FailedTGAllocs": null,
   602  		  "ClassEligibility": {
   603  			"v1:7968290453076422024": true
   604  		  }
   605  		}
   606  	  ],
   607  	  "JobModifyIndex": 0,
   608  	  "FailedTGAllocs": {
   609  		"cache": {
   610  		  "CoalescedFailures": 3,
   611  		  "AllocationTime": 46415,
   612  		  "Scores": null,
   613  		  "NodesEvaluated": 1,
   614  		  "NodesFiltered": 0,
   615  		  "NodesAvailable": {
   616  			"dc1": 1
   617  		  },
   618  		  "ClassFiltered": null,
   619  		  "ConstraintFiltered": null,
   620  		  "NodesExhausted": 1,
   621  		  "ClassExhausted": null,
   622  		  "DimensionExhausted": {
   623  			"cpu exhausted": 1
   624  		  }
   625  		}
   626  	  },
   627  	  "Annotations": {
   628  		"DesiredTGUpdates": {
   629  		  "cache": {
   630  			"DestructiveUpdate": 0,
   631  			"InPlaceUpdate": 0,
   632  			"Stop": 0,
   633  			"Migrate": 0,
   634  			"Place": 11,
   635  			"Ignore": 0
   636  		  }
   637  		}
   638  	  }
   639  	}
   640      ```
   641  
   642    </dd>
   643  
   644    <dt>Field Reference</dt>
   645    <dd>
   646      <ul>
   647        <li>
   648          <span class="param">Diff</span>
   649          A diff structure between the submitted job and the server side version.
   650          The top-level object is a Job Diff which contains Task Group Diffs,
   651          which in turn contain Task Diffs. Each of these objects then has Object
   652          and Field Diff structures embedded.
   653        </li>
   654        <li>
   655          <span class="param">NextPeriodicLaunch</span>
   656          If the job being planned is periodic, this field will include the next
   657          launch time for the job.
   658        </li>
   659        <li>
   660          <span class="param">CreatedEvals</span>
   661          A set of evaluations that were created as a result of the dry-run. These
   662          evaluations can signify a follow-up rolling update evaluation or a
   663          blocked evaluation.
   664        </li>
   665        <li>
   666          <span class="param">JobModifyIndex</span>
   667          The JobModifyIndex of the server side version of this job.
   668        </li>
   669        <li>
   670          <span class="param">FailedTGAllocs</span>
   671          A set of metrics to understand any allocation failures that occurred for
   672          the Task Group.
   673        </li>
   674        <li>
   675          <span class="param">Annotations</span>
   676          Annotations include the DesiredTGUpdates, which tracks what the
   677          scheduler would do given enough resources for each Task Group.
   678        </li>
   679      </ul>
   680    </dd>
   681  </dl>
   682  
   683  
   684  <dl>
   685    <dt>Description</dt>
   686    <dd>
   687      Forces a new instance of the periodic job. A new instance will be created
   688      even if it violates the job's
   689      [`prohibit_overlap`](/docs/job-specification/periodic.html#prohibit_overlap) settings. As
   690      such, this should be only used to immediately run a periodic job.
   691    </dd>
   692  
   693    <dt>Method</dt>
   694    <dd>PUT or POST</dd>
   695  
   696    <dt>URL</dt>
   697    <dd>`/v1/job/<ID>/periodic/force`</dd>
   698  
   699    <dt>Parameters</dt>
   700    <dd>
   701      None
   702    </dd>
   703  
   704    <dt>Returns</dt>
   705    <dd>
   706  
   707      ```javascript
   708      {
   709      "EvalCreateIndex": 7,
   710      "EvalID": "57983ddd-7fcf-3e3a-fd24-f699ccfb36f4"
   711      }
   712      ```
   713  
   714    </dd>
   715  </dl>
   716  
   717  ## DELETE
   718  
   719  <dl>
   720    <dt>Description</dt>
   721    <dd>
   722      Deregisters a job, and stops all allocations part of it.
   723    </dd>
   724  
   725    <dt>Method</dt>
   726    <dd>DELETE</dd>
   727  
   728    <dt>URL</dt>
   729    <dd>`/v1/job/<ID>`</dd>
   730  
   731    <dt>Parameters</dt>
   732    <dd>
   733      None
   734    </dd>
   735  
   736    <dt>Returns</dt>
   737    <dd>
   738  
   739      ```javascript
   740      {
   741      "EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac",
   742      "EvalCreateIndex": 35,
   743      "JobModifyIndex": 34,
   744      }
   745      ```
   746  
   747    </dd>
   748  </dl>