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