github.com/maier/nomad@v0.4.1-0.20161110003312-a9e3d0b8549d/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      "CreateIndex": 14,
   137      "ModifyIndex": 14
   138      }
   139      ```
   140  
   141    </dd>
   142  </dl>
   143  
   144  <dl>
   145    <dt>Description</dt>
   146    <dd>
   147      Query the allocations belonging to a single job.
   148    </dd>
   149  
   150    <dt>Method</dt>
   151    <dd>GET</dd>
   152  
   153    <dt>URL</dt>
   154    <dd>`/v1/job/<ID>/allocations`</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          "ID": "3575ba9d-7a12-0c96-7b28-add168c67984",
   173          "EvalID": "151accaa-1ac6-90fe-d427-313e70ccbb88",
   174          "Name": "binstore-storagelocker.binsl[0]",
   175          "NodeID": "a703c3ca-5ff8-11e5-9213-970ee8879d1b",
   176          "JobID": "binstore-storagelocker",
   177          "TaskGroup": "binsl",
   178          "DesiredStatus": "run",
   179          "DesiredDescription": "",
   180          "ClientStatus": "running",
   181          "ClientDescription": "",
   182          "CreateIndex": 16,
   183          "ModifyIndex": 16
   184      },
   185      ...
   186      ]
   187      ```
   188  
   189    </dd>
   190  </dl>
   191  
   192  <dl>
   193    <dt>Description</dt>
   194    <dd>
   195      Query the evaluations belonging to a single job.
   196    </dd>
   197  
   198    <dt>Method</dt>
   199    <dd>GET</dd>
   200  
   201    <dt>URL</dt>
   202    <dd>`/v1/job/<ID>/evaluations`</dd>
   203  
   204    <dt>Parameters</dt>
   205    <dd>
   206      None
   207    </dd>
   208  
   209    <dt>Blocking Queries</dt>
   210    <dd>
   211      [Supported](/docs/http/index.html#blocking-queries)
   212    </dd>
   213  
   214    <dt>Returns</dt>
   215    <dd>
   216  
   217      ```javascript
   218      [
   219      {
   220          "ID": "151accaa-1ac6-90fe-d427-313e70ccbb88",
   221          "Priority": 50,
   222          "Type": "service",
   223          "TriggeredBy": "job-register",
   224          "JobID": "binstore-storagelocker",
   225          "JobModifyIndex": 14,
   226          "NodeID": "",
   227          "NodeModifyIndex": 0,
   228          "Status": "complete",
   229          "StatusDescription": "",
   230          "Wait": 0,
   231          "NextEval": "",
   232          "PreviousEval": "",
   233          "CreateIndex": 15,
   234          "ModifyIndex": 17
   235      },
   236      ...
   237      ]
   238      ```
   239  
   240    </dd>
   241  </dl>
   242  
   243  <dl>
   244    <dt>Description</dt>
   245    <dd>
   246      Query the summary of a job.
   247    </dd>
   248  
   249    <dt>Method</dt>
   250    <dd>GET</dd>
   251  
   252    <dt>URL</dt>
   253    <dd>`/v1/job/<ID>/summary`</dd>
   254  
   255    <dt>Parameters</dt>
   256    <dd>
   257      None
   258    </dd>
   259  
   260    <dt>Blocking Queries</dt>
   261    <dd>
   262      [Supported](/docs/http/index.html#blocking-queries)
   263    </dd>
   264  
   265    <dt>Returns</dt>
   266    <dd>
   267  
   268      ```javascript
   269      {
   270        "JobID": "example",
   271        "Summary": {
   272          "cache": {
   273            "Queued": 0,
   274            "Complete": 0,
   275            "Failed": 0,
   276            "Running": 1,
   277            "Starting": 0,
   278            "Lost": 0
   279          }
   280        },
   281        "CreateIndex": 6,
   282        "ModifyIndex": 10
   283      }
   284      ```
   285  
   286    </dd>
   287  </dl>
   288  
   289  
   290  ## PUT / POST
   291  
   292  <dl>
   293    <dt>Description</dt>
   294    <dd>
   295      Registers a new job or updates an existing job
   296    </dd>
   297  
   298    <dt>Method</dt>
   299    <dd>PUT or POST</dd>
   300  
   301    <dt>URL</dt>
   302    <dd>`/v1/job/<ID>`</dd>
   303  
   304    <dt>Parameters</dt>
   305    <dd>
   306      <ul>
   307        <li>
   308          <span class="param">Job</span>
   309          <span class="param-flags">required</span>
   310          The JSON definition of the job.
   311        </li>
   312      </ul>
   313    </dd>
   314  
   315    <dt>Returns</dt>
   316    <dd>
   317  
   318      ```javascript
   319      {
   320      "EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac",
   321      "EvalCreateIndex": 35,
   322      "JobModifyIndex": 34,
   323      }
   324      ```
   325  
   326    </dd>
   327  </dl>
   328  
   329  <dl>
   330    <dt>Description</dt>
   331    <dd>
   332      Creates a new evaluation for the given job. This can be used to force
   333      run the scheduling logic if necessary.
   334    </dd>
   335  
   336    <dt>Method</dt>
   337    <dd>PUT or POST</dd>
   338  
   339    <dt>URL</dt>
   340    <dd>`/v1/job/<ID>/evaluate`</dd>
   341  
   342    <dt>Parameters</dt>
   343    <dd>
   344      None
   345    </dd>
   346  
   347    <dt>Returns</dt>
   348    <dd>
   349  
   350      ```javascript
   351      {
   352      "EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac",
   353      "EvalCreateIndex": 35,
   354      "JobModifyIndex": 34,
   355      }
   356      ```
   357  
   358    </dd>
   359  </dl>
   360  
   361  <dl>
   362    <dt>Description</dt>
   363    <dd>
   364      Invoke a dry-run of the scheduler for the job.
   365    </dd>
   366  
   367    <dt>Method</dt>
   368    <dd>PUT or POST</dd>
   369  
   370    <dt>URL</dt>
   371    <dd>`/v1/job/<ID>/plan`</dd>
   372  
   373    <dt>Parameters</dt>
   374    <dd>
   375      <ul>
   376        <li>
   377          <span class="param">Job</span>
   378          <span class="param-flags">required</span>
   379          The JSON definition of the job.
   380        </li>
   381        <li>
   382          <span class="param">Diff</span>
   383          <span class="param-flags">optional</span>
   384          Whether the diff structure between the submitted and server side version
   385          of the job should be included in the response.
   386        </li>
   387      </ul>
   388    </dd>
   389  
   390    <dt>Returns</dt>
   391    <dd>
   392  
   393      ```javascript
   394  	{
   395  	  "Index": 0,
   396  	  "NextPeriodicLaunch": "0001-01-01T00:00:00Z",
   397  	  "Diff": {
   398  		"Type": "Added",
   399  		"TaskGroups": [
   400  		  {
   401  			"Updates": {
   402  			  "create": 1
   403  			},
   404  			"Type": "Added",
   405  			"Tasks": [
   406  			  {
   407  				"Type": "Added",
   408  				"Objects": [...],
   409  				"Name": "redis",
   410  				"Fields": [
   411  				  {
   412  					"Type": "Added",
   413  					"Old": "",
   414  					"New": "docker",
   415  					"Name": "Driver",
   416  					"Annotations": null
   417  				  },
   418  				  {
   419  					"Type": "Added",
   420  					"Old": "",
   421  					"New": "5000000000",
   422  					"Name": "KillTimeout",
   423  					"Annotations": null
   424  				  }
   425  				],
   426  				"Annotations": [
   427  				  "forces create"
   428  				]
   429  			  }
   430  			],
   431  			"Objects": [...],
   432  			"Name": "cache",
   433  			"Fields": [...]
   434  		  }
   435  		],
   436  		"Objects": [
   437  		  {
   438  			"Type": "Added",
   439  			"Objects": null,
   440  			"Name": "Datacenters",
   441  			"Fields": [...]
   442  		  },
   443  		  {
   444  			"Type": "Added",
   445  			"Objects": null,
   446  			"Name": "Constraint",
   447  			"Fields": [...]
   448  		  },
   449  		  {
   450  			"Type": "Added",
   451  			"Objects": null,
   452  			"Name": "Update",
   453  			"Fields": [...]
   454  		  }
   455  		],
   456  		"ID": "example",
   457          "Fields": [...],
   458  		  ...
   459  		]
   460  	  },
   461  	"CreatedEvals": [
   462  		{
   463  		  "ModifyIndex": 0,
   464  		  "CreateIndex": 0,
   465  		  "SnapshotIndex": 0,
   466  		  "AnnotatePlan": false,
   467  		  "EscapedComputedClass": false,
   468  		  "NodeModifyIndex": 0,
   469  		  "NodeID": "",
   470  		  "JobModifyIndex": 0,
   471  		  "JobID": "example",
   472  		  "TriggeredBy": "job-register",
   473  		  "Type": "batch",
   474  		  "Priority": 50,
   475  		  "ID": "312e6a6d-8d01-0daf-9105-14919a66dba3",
   476  		  "Status": "blocked",
   477  		  "StatusDescription": "created to place remaining allocations",
   478  		  "Wait": 0,
   479  		  "NextEval": "",
   480  		  "PreviousEval": "80318ae4-7eda-e570-e59d-bc11df134817",
   481  		  "BlockedEval": "",
   482  		  "FailedTGAllocs": null,
   483  		  "ClassEligibility": {
   484  			"v1:7968290453076422024": true
   485  		  }
   486  		}
   487  	  ],
   488  	  "JobModifyIndex": 0,
   489  	  "FailedTGAllocs": {
   490  		"cache": {
   491  		  "CoalescedFailures": 3,
   492  		  "AllocationTime": 46415,
   493  		  "Scores": null,
   494  		  "NodesEvaluated": 1,
   495  		  "NodesFiltered": 0,
   496  		  "NodesAvailable": {
   497  			"dc1": 1
   498  		  },
   499  		  "ClassFiltered": null,
   500  		  "ConstraintFiltered": null,
   501  		  "NodesExhausted": 1,
   502  		  "ClassExhausted": null,
   503  		  "DimensionExhausted": {
   504  			"cpu exhausted": 1
   505  		  }
   506  		}
   507  	  },
   508  	  "Annotations": {
   509  		"DesiredTGUpdates": {
   510  		  "cache": {
   511  			"DestructiveUpdate": 0,
   512  			"InPlaceUpdate": 0,
   513  			"Stop": 0,
   514  			"Migrate": 0,
   515  			"Place": 11,
   516  			"Ignore": 0
   517  		  }
   518  		}
   519  	  }
   520  	}
   521      ```
   522  
   523    </dd>
   524  
   525    <dt>Field Reference</dt>
   526    <dd>
   527      <ul>
   528        <li>
   529          <span class="param">Diff</span>
   530          A diff structure between the submitted job and the server side version.
   531          The top-level object is a Job Diff which contains Task Group Diffs,
   532          which in turn contain Task Diffs. Each of these objects then has Object
   533          and Field Diff structures embedded.
   534        </li>
   535        <li>
   536          <span class="param">NextPeriodicLaunch</span>
   537          If the job being planned is periodic, this field will include the next
   538          launch time for the job.
   539        </li>
   540        <li>
   541          <span class="param">CreatedEvals</span>
   542          A set of evaluations that were created as a result of the dry-run. These
   543          evaluations can signify a follow-up rolling update evaluation or a
   544          blocked evaluation.
   545        </li>
   546        <li>
   547          <span class="param">JobModifyIndex</span>
   548          The JobModifyIndex of the server side version of this job.
   549        </li>
   550        <li>
   551          <span class="param">FailedTGAllocs</span>
   552          A set of metrics to understand any allocation failures that occurred for
   553          the Task Group.
   554        </li>
   555        <li>
   556          <span class="param">Annotations</span>
   557          Annotations include the DesiredTGUpdates, which tracks what the
   558          scheduler would do given enough resources for each Task Group.
   559        </li>
   560      </ul>
   561    </dd>
   562  </dl>
   563  
   564  
   565  <dl>
   566    <dt>Description</dt>
   567    <dd>
   568      Forces a new instance of the periodic job. A new instance will be created
   569      even if it violates the job's
   570      [`prohibit_overlap`](/docs/job-specification/periodic.html#prohibit_overlap) settings. As
   571      such, this should be only used to immediately run a periodic job.
   572    </dd>
   573  
   574    <dt>Method</dt>
   575    <dd>PUT or POST</dd>
   576  
   577    <dt>URL</dt>
   578    <dd>`/v1/job/<ID>/periodic/force`</dd>
   579  
   580    <dt>Parameters</dt>
   581    <dd>
   582      None
   583    </dd>
   584  
   585    <dt>Returns</dt>
   586    <dd>
   587  
   588      ```javascript
   589      {
   590      "EvalCreateIndex": 7,
   591      "EvalID": "57983ddd-7fcf-3e3a-fd24-f699ccfb36f4"
   592      }
   593      ```
   594  
   595    </dd>
   596  </dl>
   597  
   598  ## DELETE
   599  
   600  <dl>
   601    <dt>Description</dt>
   602    <dd>
   603      Deregisters a job, and stops all allocations part of it.
   604    </dd>
   605  
   606    <dt>Method</dt>
   607    <dd>DELETE</dd>
   608  
   609    <dt>URL</dt>
   610    <dd>`/v1/job/<ID>`</dd>
   611  
   612    <dt>Parameters</dt>
   613    <dd>
   614      None
   615    </dd>
   616  
   617    <dt>Returns</dt>
   618    <dd>
   619  
   620      ```javascript
   621      {
   622      "EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac",
   623      "EvalCreateIndex": 35,
   624      "JobModifyIndex": 34,
   625      }
   626      ```
   627  
   628    </dd>
   629  </dl>