github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/website/content/api-docs/jobs.mdx (about) 1 --- 2 layout: api 3 page_title: Jobs - HTTP API 4 sidebar_title: Jobs 5 description: The /jobs endpoints are used to query for and interact with jobs. 6 --- 7 8 # Jobs HTTP API 9 10 The `/jobs` endpoints are used to query for and interact with jobs. 11 12 ## List Jobs 13 14 This endpoint lists all known jobs in the system registered with Nomad. 15 16 | Method | Path | Produces | 17 | ------ | ---------- | ------------------ | 18 | `GET` | `/v1/jobs` | `application/json` | 19 20 The table below shows this endpoint's support for 21 [blocking queries](/api-docs#blocking-queries) and 22 [required ACLs](/api-docs#acls). 23 24 | Blocking Queries | ACL Required | 25 | ---------------- | --------------------- | 26 | `YES` | `namespace:list-jobs` | 27 28 ### Parameters 29 30 - `prefix` `(string: "")` - Specifies a string to filter jobs on based on 31 an index prefix. This is specified as a query string parameter. 32 33 - `namespace` `(string: "default")` - Specifies the target namespace. Specifying 34 `*` would return all jobs across all the authorized namespaces. 35 36 ### Sample Request 37 38 ```shell-session 39 $ curl https://localhost:4646/v1/jobs 40 ``` 41 42 ```shell-session 43 $ curl https://localhost:4646/v1/jobs?prefix=team 44 ``` 45 46 ```shell-session 47 $ curl https://localhost:4646/v1/jobs?namespace=*&prefix=team 48 ``` 49 50 ### Sample Response 51 52 ```json 53 [ 54 { 55 "ID": "example", 56 "ParentID": "", 57 "Name": "example", 58 "Type": "service", 59 "Priority": 50, 60 "Status": "pending", 61 "StatusDescription": "", 62 "JobSummary": { 63 "JobID": "example", 64 "Namespace": "default", 65 "Summary": { 66 "cache": { 67 "Queued": 1, 68 "Complete": 1, 69 "Failed": 0, 70 "Running": 0, 71 "Starting": 0, 72 "Lost": 0 73 } 74 }, 75 "Children": { 76 "Pending": 0, 77 "Running": 0, 78 "Dead": 0 79 }, 80 "CreateIndex": 52, 81 "ModifyIndex": 96 82 }, 83 "CreateIndex": 52, 84 "ModifyIndex": 93, 85 "JobModifyIndex": 52 86 } 87 ] 88 ``` 89 90 ## Create Job 91 92 This endpoint creates (aka "registers") a new job in the system. 93 94 | Method | Path | Produces | 95 | ------ | ---------- | ------------------ | 96 | `POST` | `/v1/jobs` | `application/json` | 97 98 The table below shows this endpoint's support for 99 [blocking queries](/api-docs#blocking-queries) and 100 [required ACLs](/api-docs#acls). 101 102 | Blocking Queries | ACL Required | 103 | ---------------- | --------------------------------------------------------------------------------- | 104 | `NO` | `namespace:submit-job`<br />`namespace:sentinel-override` if `PolicyOverride` set | 105 106 ### Parameters 107 108 - `Job` `(Job: <required>)` - Specifies the JSON definition of the job. 109 110 - `EnforceIndex` `(bool: false)` - If set, the job will only be registered if the 111 passed `JobModifyIndex` matches the current job's index. If the index is zero, 112 the register only occurs if the job is new. This paradigm allows check-and-set 113 style job updating. 114 115 - `JobModifyIndex` `(int: 0)` - Specifies the `JobModifyIndex` to enforce the 116 current job is at. 117 118 - `PolicyOverride` `(bool: false)` - If set, any soft mandatory Sentinel 119 policies will be overridden. This allows a job to be registered when it would 120 be denied by policy. 121 122 - `PreserveCounts` `(bool: false)` - If set, existing task group counts are 123 preserved, over those specified in the new job spec. 124 125 ### Sample Payload 126 127 ```json 128 { 129 "EnforceIndex": false, 130 "PreserveCounts": true, 131 "PolicyOverride": false, 132 "JobModifyIndex": 0, 133 "Job": { 134 "ID": "example", 135 "Name": "example", 136 "Type": "service", 137 "Priority": 50, 138 "Datacenters": ["dc1"], 139 "TaskGroups": [ 140 { 141 "Name": "cache", 142 "Count": 1, 143 "Tasks": [ 144 { 145 "Name": "redis", 146 "Driver": "docker", 147 "User": "", 148 "Config": { 149 "image": "redis:3.2", 150 "port_map": [ 151 { 152 "db": 6379 153 } 154 ] 155 }, 156 "Services": [ 157 { 158 "Id": "", 159 "Name": "redis-cache", 160 "Tags": ["global", "cache"], 161 "Meta": { 162 "meta": "for my service" 163 }, 164 "PortLabel": "db", 165 "AddressMode": "", 166 "Checks": [ 167 { 168 "Id": "", 169 "Name": "alive", 170 "Type": "tcp", 171 "Command": "", 172 "Args": null, 173 "Path": "", 174 "Protocol": "", 175 "PortLabel": "", 176 "Interval": 10000000000, 177 "Timeout": 2000000000, 178 "InitialStatus": "", 179 "TLSSkipVerify": false 180 } 181 ] 182 } 183 ], 184 "Resources": { 185 "CPU": 500, 186 "MemoryMB": 256, 187 "Networks": [ 188 { 189 "Device": "", 190 "CIDR": "", 191 "IP": "", 192 "MBits": 10, 193 "DynamicPorts": [ 194 { 195 "Label": "db", 196 "Value": 0 197 } 198 ] 199 } 200 ] 201 }, 202 "Leader": false 203 } 204 ], 205 "RestartPolicy": { 206 "Interval": 300000000000, 207 "Attempts": 10, 208 "Delay": 25000000000, 209 "Mode": "delay" 210 }, 211 "ReschedulePolicy": { 212 "Attempts": 10, 213 "Delay": 30000000000, 214 "DelayFunction": "exponential", 215 "Interval": 36000000000000, 216 "MaxDelay": 3600000000000, 217 "Unlimited": false 218 }, 219 "EphemeralDisk": { 220 "SizeMB": 300 221 } 222 } 223 ], 224 "Update": { 225 "MaxParallel": 1, 226 "MinHealthyTime": 10000000000, 227 "HealthyDeadline": 180000000000, 228 "AutoRevert": false, 229 "Canary": 0 230 } 231 } 232 } 233 ``` 234 235 ### Sample Request 236 237 ```shell-session 238 $ curl \ 239 --request POST \ 240 --data @payload.json \ 241 https://localhost:4646/v1/jobs 242 ``` 243 244 ### Sample Response 245 246 ```json 247 { 248 "EvalID": "", 249 "EvalCreateIndex": 0, 250 "JobModifyIndex": 109, 251 "Warnings": "", 252 "Index": 0, 253 "LastContact": 0, 254 "KnownLeader": false 255 } 256 ``` 257 258 ## Parse Job 259 260 This endpoint will parse a HCL jobspec and produce the equivalent JSON encoded 261 job. 262 263 | Method | Path | Produces | 264 | ------ | ---------------- | ------------------ | 265 | `POST` | `/v1/jobs/parse` | `application/json` | 266 267 The table below shows this endpoint's support for 268 [blocking queries](/api-docs#blocking-queries) and 269 [required ACLs](/api-docs#acls). 270 271 | Blocking Queries | ACL Required | 272 | ---------------- | ------------ | 273 | `NO` | `none` | 274 275 ### Parameters 276 277 - `JobHCL` `(string: <required>)` - Specifies the HCL definition of the job 278 encoded in a JSON string. 279 - `Canonicalize` `(bool: false)` - Flag to enable setting any unset fields to 280 their default values. 281 282 ## Sample Payload 283 284 ```json 285 { 286 "JobHCL": "job \"example\" { type = \"service\" group \"cache\" {} }", 287 "Canonicalize": true 288 } 289 ``` 290 291 ### Sample Request 292 293 ```shell-session 294 $ curl \ 295 --request POST \ 296 --data @payload.json \ 297 https://localhost:4646/v1/jobs/parse 298 ``` 299 300 ### Sample Response 301 302 ```json 303 { 304 "AllAtOnce": false, 305 "Constraints": null, 306 "Affinities": null, 307 "CreateIndex": 0, 308 "Datacenters": null, 309 "ID": "my-job", 310 "JobModifyIndex": 0, 311 "Meta": null, 312 "Migrate": null, 313 "ModifyIndex": 0, 314 "Name": "my-job", 315 "Namespace": "default", 316 "ParameterizedJob": null, 317 "ParentID": "", 318 "Payload": null, 319 "Periodic": null, 320 "Priority": 50, 321 "Region": "global", 322 "Reschedule": null, 323 "Stable": false, 324 "Status": "", 325 "StatusDescription": "", 326 "Stop": false, 327 "SubmitTime": null, 328 "TaskGroups": null, 329 "Type": "service", 330 "Update": null, 331 "VaultToken": "", 332 "Version": 0 333 } 334 ``` 335 336 ## Read Job 337 338 This endpoint reads information about a single job for its specification and 339 status. 340 341 | Method | Path | Produces | 342 | ------ | ----------------- | ------------------ | 343 | `GET` | `/v1/job/:job_id` | `application/json` | 344 345 The table below shows this endpoint's support for 346 [blocking queries](/api-docs#blocking-queries) and 347 [required ACLs](/api-docs#acls). 348 349 | Blocking Queries | ACL Required | 350 | ---------------- | -------------------- | 351 | `YES` | `namespace:read-job` | 352 353 ### Parameters 354 355 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 356 the job file during submission). This is specified as part of the path. 357 358 ### Sample Request 359 360 ```shell-session 361 $ curl \ 362 https://localhost:4646/v1/job/my-job 363 ``` 364 365 ### Sample Response 366 367 ```json 368 { 369 "Region": "global", 370 "ID": "example", 371 "ParentID": "", 372 "Name": "example", 373 "Type": "batch", 374 "Priority": 50, 375 "AllAtOnce": false, 376 "Datacenters": ["dc1"], 377 "Constraints": [ 378 { 379 "LTarget": "${attr.kernel.name}", 380 "RTarget": "linux", 381 "Operand": "=" 382 } 383 ], 384 "TaskGroups": [ 385 { 386 "Name": "cache", 387 "Count": 1, 388 "Constraints": [ 389 { 390 "LTarget": "${attr.os.signals}", 391 "RTarget": "SIGUSR1", 392 "Operand": "set_contains" 393 } 394 ], 395 "Affinities": [ 396 { 397 "LTarget": "${meta.datacenter}", 398 "RTarget": "dc1", 399 "Operand": "=", 400 "Weight": 50 401 } 402 ], 403 "RestartPolicy": { 404 "Attempts": 10, 405 "Interval": 300000000000, 406 "Delay": 25000000000, 407 "Mode": "delay" 408 }, 409 "Tasks": [ 410 { 411 "Config": { 412 "command": "env", 413 "image": "alpine" 414 }, 415 "Driver": "docker", 416 "Lifecycle": { 417 "Hook": "prestart", 418 "Sidecar": false 419 }, 420 "Name": "init", 421 "Resources": { 422 "CPU": 100, 423 "MemoryMB": 300, 424 }, 425 }, 426 { 427 "Name": "redis", 428 "Driver": "docker", 429 "User": "foo-user", 430 "Config": { 431 "image": "redis:latest", 432 "port_map": [ 433 { 434 "db": 6379 435 } 436 ] 437 }, 438 "Env": { 439 "foo": "bar", 440 "baz": "pipe" 441 }, 442 "Services": [ 443 { 444 "Name": "cache-redis", 445 "PortLabel": "db", 446 "Tags": ["global", "cache"], 447 "Checks": [ 448 { 449 "Name": "alive", 450 "Type": "tcp", 451 "Command": "", 452 "Args": null, 453 "Path": "", 454 "Protocol": "", 455 "PortLabel": "", 456 "Interval": 10000000000, 457 "Timeout": 2000000000, 458 "InitialStatus": "" 459 } 460 ] 461 } 462 ], 463 "Vault": null, 464 "Templates": [ 465 { 466 "SourcePath": "local/config.conf.tpl", 467 "DestPath": "local/config.conf", 468 "EmbeddedTmpl": "", 469 "ChangeMode": "signal", 470 "ChangeSignal": "SIGUSR1", 471 "Splay": 5000000000, 472 "Perms": "" 473 } 474 ], 475 "Constraints": null, 476 "Affinities": null, 477 "Resources": { 478 "CPU": 500, 479 "MemoryMB": 256, 480 "DiskMB": 0, 481 "Networks": [ 482 { 483 "Device": "", 484 "CIDR": "", 485 "IP": "", 486 "MBits": 10, 487 "ReservedPorts": [ 488 { 489 "Label": "rpc", 490 "Value": 25566 491 } 492 ], 493 "DynamicPorts": [ 494 { 495 "Label": "db", 496 "Value": 0 497 } 498 ] 499 } 500 ] 501 }, 502 "DispatchPayload": { 503 "File": "config.json" 504 }, 505 "Meta": { 506 "foo": "bar", 507 "baz": "pipe" 508 }, 509 "KillTimeout": 5000000000, 510 "LogConfig": { 511 "MaxFiles": 10, 512 "MaxFileSizeMB": 10 513 }, 514 "Artifacts": [ 515 { 516 "GetterSource": "http://foo.com/artifact.tar.gz", 517 "GetterOptions": { 518 "checksum": "md5:c4aa853ad2215426eb7d70a21922e794" 519 }, 520 "RelativeDest": "local/" 521 } 522 ], 523 "Leader": false 524 } 525 ], 526 "EphemeralDisk": { 527 "Sticky": false, 528 "SizeMB": 300, 529 "Migrate": false 530 }, 531 "Meta": { 532 "foo": "bar", 533 "baz": "pipe" 534 } 535 } 536 ], 537 "Update": { 538 "Stagger": 10000000000, 539 "MaxParallel": 1 540 }, 541 "Periodic": { 542 "Enabled": true, 543 "Spec": "* * * * *", 544 "SpecType": "cron", 545 "ProhibitOverlap": true 546 }, 547 "ParameterizedJob": { 548 "Payload": "required", 549 "MetaRequired": ["foo"], 550 "MetaOptional": ["bar"] 551 }, 552 "Payload": null, 553 "Meta": { 554 "foo": "bar", 555 "baz": "pipe" 556 }, 557 "VaultToken": "", 558 "Status": "running", 559 "StatusDescription": "", 560 "CreateIndex": 7, 561 "ModifyIndex": 7, 562 "JobModifyIndex": 7 563 } 564 ``` 565 566 #### Field Reference 567 568 - `Status`: The job's current state. It can have one of the following values: 569 - `pending`: The job is currently waiting on scheduling. 570 - `running`: The job has non-terminal allocations. 571 - `dead`: All of the job's allocations and evaluations are terminal. 572 - `Type`: The type of job in terms of scheduling. It can have one of the following values: 573 - `service`: Allocations are intended to remain alive. 574 - `batch`: Allocations are intended to exit. 575 - `system`: Each client gets an allocation. 576 577 ## List Job Versions 578 579 This endpoint reads information about all versions of a job. 580 581 | Method | Path | Produces | 582 | ------ | -------------------------- | ------------------ | 583 | `GET` | `/v1/job/:job_id/versions` | `application/json` | 584 585 The table below shows this endpoint's support for 586 [blocking queries](/api-docs#blocking-queries) and 587 [required ACLs](/api-docs#acls). 588 589 | Blocking Queries | ACL Required | 590 | ---------------- | -------------------- | 591 | `YES` | `namespace:read-job` | 592 593 ### Parameters 594 595 - `diffs` `(bool: false)` - Specifies if the Diffs field should be populated, 596 containing the structured diff between the current and last job version. 597 598 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 599 the job file during submission). This is specified as part of the path. 600 601 ### Sample Request 602 603 ```shell-session 604 $ curl \ 605 https://localhost:4646/v1/job/my-job/versions 606 ``` 607 608 ### Sample Response 609 610 ```json 611 { 612 "Diffs": null, 613 "Index": 51, 614 "KnownLeader": true, 615 "LastContact": 0, 616 "Versions": [ 617 { 618 "Affinities": null, 619 "AllAtOnce": false, 620 "Constraints": null, 621 "ConsulToken": "", 622 "CreateIndex": 44, 623 "Datacenters": ["dc1"], 624 "Dispatched": false, 625 "ID": "example", 626 "JobModifyIndex": 44, 627 "Meta": null, 628 "ModifyIndex": 51, 629 "Multiregion": null, 630 "Name": "example", 631 "Namespace": "default", 632 "NomadTokenID": "", 633 "ParameterizedJob": null, 634 "ParentID": "", 635 "Payload": null, 636 "Periodic": null, 637 "Priority": 50, 638 "Region": "global", 639 "Spreads": null, 640 "Stable": true, 641 "Status": "running", 642 "StatusDescription": "", 643 "Stop": false, 644 "SubmitTime": 1608304897537638400, 645 "TaskGroups": [ 646 { 647 "Affinities": null, 648 "Constraints": null, 649 "Count": 1, 650 "EphemeralDisk": { 651 "Migrate": false, 652 "SizeMB": 300, 653 "Sticky": false 654 }, 655 "Meta": null, 656 "Migrate": { 657 "HealthCheck": "checks", 658 "HealthyDeadline": 300000000000, 659 "MaxParallel": 1, 660 "MinHealthyTime": 10000000000 661 }, 662 "Name": "cache", 663 "Networks": [ 664 { 665 "CIDR": "", 666 "DNS": null, 667 "Device": "", 668 "DynamicPorts": [ 669 { 670 "HostNetwork": "default", 671 "Label": "db", 672 "To": 6379, 673 "Value": 0 674 } 675 ], 676 "IP": "", 677 "MBits": 0, 678 "Mode": "", 679 "ReservedPorts": null 680 } 681 ], 682 "ReschedulePolicy": { 683 "Attempts": 0, 684 "Delay": 30000000000, 685 "DelayFunction": "exponential", 686 "Interval": 0, 687 "MaxDelay": 3600000000000, 688 "Unlimited": true 689 }, 690 "RestartPolicy": { 691 "Attempts": 2, 692 "Delay": 15000000000, 693 "Interval": 1800000000000, 694 "Mode": "fail" 695 }, 696 "Scaling": null, 697 "Services": null, 698 "ShutdownDelay": null, 699 "Spreads": null, 700 "StopAfterClientDisconnect": null, 701 "Tasks": [ 702 { 703 "Affinities": null, 704 "Artifacts": null, 705 "CSIPluginConfig": null, 706 "Config": { 707 "image": "redis:3.2", 708 "ports": ["db"] 709 }, 710 "Constraints": null, 711 "DispatchPayload": null, 712 "Driver": "docker", 713 "Env": null, 714 "KillSignal": "", 715 "KillTimeout": 5000000000, 716 "Kind": "", 717 "Leader": false, 718 "Lifecycle": null, 719 "LogConfig": { 720 "MaxFileSizeMB": 10, 721 "MaxFiles": 10 722 }, 723 "Meta": null, 724 "Name": "redis", 725 "Resources": { 726 "CPU": 500, 727 "Devices": null, 728 "DiskMB": 0, 729 "IOPS": 0, 730 "MemoryMB": 256, 731 "Networks": null 732 }, 733 "RestartPolicy": { 734 "Attempts": 2, 735 "Delay": 15000000000, 736 "Interval": 1800000000000, 737 "Mode": "fail" 738 }, 739 "ScalingPolicies": null, 740 "Services": null, 741 "ShutdownDelay": 0, 742 "Templates": null, 743 "User": "", 744 "Vault": null, 745 "VolumeMounts": null 746 } 747 ], 748 "Update": { 749 "AutoPromote": false, 750 "AutoRevert": false, 751 "Canary": 0, 752 "HealthCheck": "checks", 753 "HealthyDeadline": 300000000000, 754 "MaxParallel": 1, 755 "MinHealthyTime": 10000000000, 756 "ProgressDeadline": 600000000000, 757 "Stagger": 30000000000 758 }, 759 "Volumes": null 760 } 761 ], 762 "Type": "service", 763 "Update": { 764 "AutoPromote": false, 765 "AutoRevert": false, 766 "Canary": 0, 767 "HealthCheck": "", 768 "HealthyDeadline": 0, 769 "MaxParallel": 1, 770 "MinHealthyTime": 0, 771 "ProgressDeadline": 0, 772 "Stagger": 30000000000 773 }, 774 "VaultNamespace": "", 775 "VaultToken": "", 776 "Version": 0 777 } 778 ] 779 } 780 ``` 781 782 ```shell-session 783 $ curl \ 784 https://localhost:4646/v1/job/my-job/versions?diffs=true 785 ``` 786 787 ``` 788 789 { 790 "Diffs": [ 791 { 792 "Fields": null, 793 "ID": "example", 794 "Objects": null, 795 "TaskGroups": [ 796 { 797 "Fields": null, 798 "Name": "cache", 799 "Objects": null, 800 "Tasks": [ 801 { 802 "Annotations": null, 803 "Fields": [ 804 { 805 "Annotations": null, 806 "Name": "Env[foo]", 807 "New": "bar", 808 "Old": "", 809 "Type": "Added" 810 } 811 ], 812 "Name": "redis", 813 "Objects": null, 814 "Type": "Edited" 815 } 816 ], 817 "Type": "Edited", 818 "Updates": null 819 } 820 ], 821 "Type": "Edited" 822 } 823 ], 824 "Index": 26, 825 "KnownLeader": true, 826 "LastContact": 0, 827 "Versions": [ 828 { 829 "Affinities": null, 830 "AllAtOnce": false, 831 "Constraints": null, 832 "ConsulToken": "", 833 "CreateIndex": 10, 834 "Datacenters": [ 835 "dc1" 836 ], 837 "Dispatched": false, 838 "ID": "example", 839 "JobModifyIndex": 16, 840 "Meta": null, 841 "ModifyIndex": 26, 842 "Multiregion": null, 843 "Name": "example", 844 "Namespace": "default", 845 "NomadTokenID": "", 846 "ParameterizedJob": null, 847 "ParentID": "", 848 "Payload": null, 849 "Periodic": null, 850 "Priority": 50, 851 "Region": "global", 852 "Spreads": null, 853 "Stable": true, 854 "Status": "running", 855 "StatusDescription": "", 856 "Stop": false, 857 "SubmitTime": 1608316675000588800, 858 "TaskGroups": [ 859 { 860 "Affinities": null, 861 "Constraints": null, 862 "Count": 1, 863 "EphemeralDisk": { 864 "Migrate": false, 865 "SizeMB": 300, 866 "Sticky": false 867 }, 868 "Meta": null, 869 "Migrate": { 870 "HealthCheck": "checks", 871 "HealthyDeadline": 300000000000, 872 "MaxParallel": 1, 873 "MinHealthyTime": 10000000000 874 }, 875 "Name": "cache", 876 "Networks": [ 877 { 878 "CIDR": "", 879 "DNS": null, 880 "Device": "", 881 "DynamicPorts": [ 882 { 883 "HostNetwork": "default", 884 "Label": "db", 885 "To": 6379, 886 "Value": 0 887 } 888 ], 889 "IP": "", 890 "MBits": 0, 891 "Mode": "", 892 "ReservedPorts": null 893 } 894 ], 895 "ReschedulePolicy": { 896 "Attempts": 0, 897 "Delay": 30000000000, 898 "DelayFunction": "exponential", 899 "Interval": 0, 900 "MaxDelay": 3600000000000, 901 "Unlimited": true 902 }, 903 "RestartPolicy": { 904 "Attempts": 2, 905 "Delay": 15000000000, 906 "Interval": 1800000000000, 907 "Mode": "fail" 908 }, 909 "Scaling": null, 910 "Services": null, 911 "ShutdownDelay": null, 912 "Spreads": null, 913 "StopAfterClientDisconnect": null, 914 "Tasks": [ 915 { 916 "Affinities": null, 917 "Artifacts": null, 918 "CSIPluginConfig": null, 919 "Config": { 920 "image": "redis:3.2", 921 "ports": [ 922 "db" 923 ] 924 }, 925 "Constraints": null, 926 "DispatchPayload": null, 927 "Driver": "docker", 928 "Env": { 929 "foo": "bar" 930 }, 931 "KillSignal": "", 932 "KillTimeout": 5000000000, 933 "Kind": "", 934 "Leader": false, 935 "Lifecycle": null, 936 "LogConfig": { 937 "MaxFileSizeMB": 10, 938 "MaxFiles": 10 939 }, 940 "Meta": null, 941 "Name": "redis", 942 "Resources": { 943 "CPU": 500, 944 "Devices": null, 945 "DiskMB": 0, 946 "IOPS": 0, 947 "MemoryMB": 256, 948 "Networks": null 949 }, 950 "RestartPolicy": { 951 "Attempts": 2, 952 "Delay": 15000000000, 953 "Interval": 1800000000000, 954 "Mode": "fail" 955 }, 956 "ScalingPolicies": null, 957 "Services": null, 958 "ShutdownDelay": 0, 959 "Templates": null, 960 "User": "", 961 "Vault": null, 962 "VolumeMounts": null 963 } 964 ], 965 "Update": { 966 "AutoPromote": false, 967 "AutoRevert": false, 968 "Canary": 0, 969 "HealthCheck": "checks", 970 "HealthyDeadline": 300000000000, 971 "MaxParallel": 1, 972 "MinHealthyTime": 10000000000, 973 "ProgressDeadline": 600000000000, 974 "Stagger": 30000000000 975 }, 976 "Volumes": null 977 } 978 ], 979 "Type": "service", 980 "Update": { 981 "AutoPromote": false, 982 "AutoRevert": false, 983 "Canary": 0, 984 "HealthCheck": "", 985 "HealthyDeadline": 0, 986 "MaxParallel": 1, 987 "MinHealthyTime": 0, 988 "ProgressDeadline": 0, 989 "Stagger": 30000000000 990 }, 991 "VaultNamespace": "", 992 "VaultToken": "", 993 "Version": 1 994 }, 995 { 996 "Affinities": null, 997 "AllAtOnce": false, 998 "Constraints": null, 999 "ConsulToken": "", 1000 "CreateIndex": 10, 1001 "Datacenters": [ 1002 "dc1" 1003 ], 1004 "Dispatched": false, 1005 "ID": "example", 1006 "JobModifyIndex": 10, 1007 "Meta": null, 1008 "ModifyIndex": 10, 1009 "Multiregion": null, 1010 "Name": "example", 1011 "Namespace": "default", 1012 "NomadTokenID": "", 1013 "ParameterizedJob": null, 1014 "ParentID": "", 1015 "Payload": null, 1016 "Periodic": null, 1017 "Priority": 50, 1018 "Region": "global", 1019 "Spreads": null, 1020 "Stable": false, 1021 "Status": "pending", 1022 "StatusDescription": "", 1023 "Stop": false, 1024 "SubmitTime": 1608316662268190500, 1025 "TaskGroups": [ 1026 { 1027 "Affinities": null, 1028 "Constraints": null, 1029 "Count": 1, 1030 "EphemeralDisk": { 1031 "Migrate": false, 1032 "SizeMB": 300, 1033 "Sticky": false 1034 }, 1035 "Meta": null, 1036 "Migrate": { 1037 "HealthCheck": "checks", 1038 "HealthyDeadline": 300000000000, 1039 "MaxParallel": 1, 1040 "MinHealthyTime": 10000000000 1041 }, 1042 "Name": "cache", 1043 "Networks": [ 1044 { 1045 "CIDR": "", 1046 "DNS": null, 1047 "Device": "", 1048 "DynamicPorts": [ 1049 { 1050 "HostNetwork": "default", 1051 "Label": "db", 1052 "To": 6379, 1053 "Value": 0 1054 } 1055 ], 1056 "IP": "", 1057 "MBits": 0, 1058 "Mode": "", 1059 "ReservedPorts": null 1060 } 1061 ], 1062 "ReschedulePolicy": { 1063 "Attempts": 0, 1064 "Delay": 30000000000, 1065 "DelayFunction": "exponential", 1066 "Interval": 0, 1067 "MaxDelay": 3600000000000, 1068 "Unlimited": true 1069 }, 1070 "RestartPolicy": { 1071 "Attempts": 2, 1072 "Delay": 15000000000, 1073 "Interval": 1800000000000, 1074 "Mode": "fail" 1075 }, 1076 "Scaling": null, 1077 "Services": null, 1078 "ShutdownDelay": null, 1079 "Spreads": null, 1080 "StopAfterClientDisconnect": null, 1081 "Tasks": [ 1082 { 1083 "Affinities": null, 1084 "Artifacts": null, 1085 "CSIPluginConfig": null, 1086 "Config": { 1087 "image": "redis:3.2", 1088 "ports": [ 1089 "db" 1090 ] 1091 }, 1092 "Constraints": null, 1093 "DispatchPayload": null, 1094 "Driver": "docker", 1095 "Env": null, 1096 "KillSignal": "", 1097 "KillTimeout": 5000000000, 1098 "Kind": "", 1099 "Leader": false, 1100 "Lifecycle": null, 1101 "LogConfig": { 1102 "MaxFileSizeMB": 10, 1103 "MaxFiles": 10 1104 }, 1105 "Meta": null, 1106 "Name": "redis", 1107 "Resources": { 1108 "CPU": 500, 1109 "Devices": null, 1110 "DiskMB": 0, 1111 "IOPS": 0, 1112 "MemoryMB": 256, 1113 "Networks": null 1114 }, 1115 "RestartPolicy": { 1116 "Attempts": 2, 1117 "Delay": 15000000000, 1118 "Interval": 1800000000000, 1119 "Mode": "fail" 1120 }, 1121 "ScalingPolicies": null, 1122 "Services": null, 1123 "ShutdownDelay": 0, 1124 "Templates": null, 1125 "User": "", 1126 "Vault": null, 1127 "VolumeMounts": null 1128 } 1129 ], 1130 "Update": { 1131 "AutoPromote": false, 1132 "AutoRevert": false, 1133 "Canary": 0, 1134 "HealthCheck": "checks", 1135 "HealthyDeadline": 300000000000, 1136 "MaxParallel": 1, 1137 "MinHealthyTime": 10000000000, 1138 "ProgressDeadline": 600000000000, 1139 "Stagger": 30000000000 1140 }, 1141 "Volumes": null 1142 } 1143 ], 1144 "Type": "service", 1145 "Update": { 1146 "AutoPromote": false, 1147 "AutoRevert": false, 1148 "Canary": 0, 1149 "HealthCheck": "", 1150 "HealthyDeadline": 0, 1151 "MaxParallel": 1, 1152 "MinHealthyTime": 0, 1153 "ProgressDeadline": 0, 1154 "Stagger": 30000000000 1155 }, 1156 "VaultNamespace": "", 1157 "VaultToken": "", 1158 "Version": 0 1159 } 1160 ] 1161 } 1162 ``` 1163 1164 ## List Job Allocations 1165 1166 This endpoint reads information about a single job's allocations. 1167 1168 | Method | Path | Produces | 1169 | ------ | ----------------------------- | ------------------ | 1170 | `GET` | `/v1/job/:job_id/allocations` | `application/json` | 1171 1172 The table below shows this endpoint's support for 1173 [blocking queries](/api-docs#blocking-queries) and 1174 [required ACLs](/api-docs#acls). 1175 1176 | Blocking Queries | ACL Required | 1177 | ---------------- | -------------------- | 1178 | `YES` | `namespace:read-job` | 1179 1180 ### Parameters 1181 1182 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 1183 the job file during submission). This is specified as part of the path. 1184 1185 - `all` `(bool: false)` - Specifies whether the list of allocations should 1186 include allocations from a previously registered job with the same ID. This is 1187 possible if the job is deregistered and reregistered. 1188 1189 ### Sample Request 1190 1191 ```shell-session 1192 $ curl \ 1193 https://localhost:4646/v1/job/my-job/allocations 1194 ``` 1195 1196 ### Sample Response 1197 1198 ```json 1199 [ 1200 { 1201 "ID": "ed344e0a-7290-d117-41d3-a64f853ca3c2", 1202 "EvalID": "a9c5effc-2242-51b2-f1fe-054ee11ab189", 1203 "Name": "example.cache[0]", 1204 "NodeID": "cb1f6030-a220-4f92-57dc-7baaabdc3823", 1205 "PreviousAllocation": "516d2753-0513-cfc7-57ac-2d6fac18b9dc", 1206 "NextAllocation": "cd13d9b9-4f97-7184-c88b-7b451981616b", 1207 "RescheduleTracker": { 1208 "Events": [ 1209 { 1210 "PrevAllocID": "516d2753-0513-cfc7-57ac-2d6fac18b9dc", 1211 "PrevNodeID": "9230cd3b-3bda-9a3f-82f9-b2ea8dedb20e", 1212 "RescheduleTime": 1517434161192946200, 1213 "Delay": 5000000000 1214 } 1215 ] 1216 }, 1217 "JobID": "example", 1218 "TaskGroup": "cache", 1219 "DesiredStatus": "run", 1220 "DesiredDescription": "", 1221 "ClientStatus": "running", 1222 "ClientDescription": "", 1223 "TaskStates": { 1224 "redis": { 1225 "State": "running", 1226 "Failed": false, 1227 "StartedAt": "2017-05-25T23:41:23.240184101Z", 1228 "FinishedAt": "0001-01-01T00:00:00Z", 1229 "Events": [ 1230 { 1231 "Type": "Received", 1232 "Time": 1495755675956923000, 1233 "FailsTask": false, 1234 "RestartReason": "", 1235 "SetupError": "", 1236 "DriverError": "", 1237 "ExitCode": 0, 1238 "Signal": 0, 1239 "Message": "", 1240 "KillTimeout": 0, 1241 "KillError": "", 1242 "KillReason": "", 1243 "StartDelay": 0, 1244 "DownloadError": "", 1245 "ValidationError": "", 1246 "DiskLimit": 0, 1247 "FailedSibling": "", 1248 "VaultError": "", 1249 "TaskSignalReason": "", 1250 "TaskSignal": "", 1251 "DriverMessage": "" 1252 }, 1253 { 1254 "Type": "Task Setup", 1255 "Time": 1495755675957466400, 1256 "FailsTask": false, 1257 "RestartReason": "", 1258 "SetupError": "", 1259 "DriverError": "", 1260 "ExitCode": 0, 1261 "Signal": 0, 1262 "Message": "Building Task Directory", 1263 "KillTimeout": 0, 1264 "KillError": "", 1265 "KillReason": "", 1266 "StartDelay": 0, 1267 "DownloadError": "", 1268 "ValidationError": "", 1269 "DiskLimit": 0, 1270 "FailedSibling": "", 1271 "VaultError": "", 1272 "TaskSignalReason": "", 1273 "TaskSignal": "", 1274 "DriverMessage": "" 1275 }, 1276 { 1277 "Type": "Driver", 1278 "Time": 1495755675970286800, 1279 "FailsTask": false, 1280 "RestartReason": "", 1281 "SetupError": "", 1282 "DriverError": "", 1283 "ExitCode": 0, 1284 "Signal": 0, 1285 "Message": "", 1286 "KillTimeout": 0, 1287 "KillError": "", 1288 "KillReason": "", 1289 "StartDelay": 0, 1290 "DownloadError": "", 1291 "ValidationError": "", 1292 "DiskLimit": 0, 1293 "FailedSibling": "", 1294 "VaultError": "", 1295 "TaskSignalReason": "", 1296 "TaskSignal": "", 1297 "DriverMessage": "Downloading image redis:3.2" 1298 }, 1299 { 1300 "Type": "Started", 1301 "Time": 1495755683227522000, 1302 "FailsTask": false, 1303 "RestartReason": "", 1304 "SetupError": "", 1305 "DriverError": "", 1306 "ExitCode": 0, 1307 "Signal": 0, 1308 "Message": "", 1309 "KillTimeout": 0, 1310 "KillError": "", 1311 "KillReason": "", 1312 "StartDelay": 0, 1313 "DownloadError": "", 1314 "ValidationError": "", 1315 "DiskLimit": 0, 1316 "FailedSibling": "", 1317 "VaultError": "", 1318 "TaskSignalReason": "", 1319 "TaskSignal": "", 1320 "DriverMessage": "" 1321 } 1322 ] 1323 } 1324 }, 1325 "CreateIndex": 9, 1326 "ModifyIndex": 13, 1327 "CreateTime": 1495755675944527600, 1328 "ModifyTime": 1495755675944527600 1329 } 1330 ] 1331 ``` 1332 1333 ## List Job Evaluations 1334 1335 This endpoint reads information about a single job's evaluations 1336 1337 | Method | Path | Produces | 1338 | ------ | ----------------------------- | ------------------ | 1339 | `GET` | `/v1/job/:job_id/evaluations` | `application/json` | 1340 1341 The table below shows this endpoint's support for 1342 [blocking queries](/api-docs#blocking-queries) and 1343 [required ACLs](/api-docs#acls). 1344 1345 | Blocking Queries | ACL Required | 1346 | ---------------- | -------------------- | 1347 | `YES` | `namespace:read-job` | 1348 1349 ### Parameters 1350 1351 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 1352 the job file during submission). This is specified as part of the path. 1353 1354 ### Sample Request 1355 1356 ```shell-session 1357 $ curl \ 1358 https://localhost:4646/v1/job/my-job/evaluations 1359 ``` 1360 1361 ### Sample Response 1362 1363 ```json 1364 [ 1365 { 1366 "ID": "a9c5effc-2242-51b2-f1fe-054ee11ab189", 1367 "Priority": 50, 1368 "Type": "service", 1369 "TriggeredBy": "job-register", 1370 "JobID": "example", 1371 "JobModifyIndex": 7, 1372 "NodeID": "", 1373 "NodeModifyIndex": 0, 1374 "Status": "complete", 1375 "StatusDescription": "", 1376 "Wait": 0, 1377 "NextEval": "", 1378 "PreviousEval": "", 1379 "BlockedEval": "", 1380 "FailedTGAllocs": null, 1381 "ClassEligibility": null, 1382 "EscapedComputedClass": false, 1383 "AnnotatePlan": false, 1384 "QueuedAllocations": { 1385 "cache": 0 1386 }, 1387 "SnapshotIndex": 8, 1388 "CreateIndex": 8, 1389 "ModifyIndex": 10 1390 } 1391 ] 1392 ``` 1393 1394 ## List Job Deployments 1395 1396 This endpoint lists a single job's deployments 1397 1398 | Method | Path | Produces | 1399 | ------ | ----------------------------- | ------------------ | 1400 | `GET` | `/v1/job/:job_id/deployments` | `application/json` | 1401 1402 The table below shows this endpoint's support for 1403 [blocking queries](/api-docs#blocking-queries) and 1404 [required ACLs](/api-docs#acls). 1405 1406 | Blocking Queries | ACL Required | 1407 | ---------------- | -------------------- | 1408 | `YES` | `namespace:read-job` | 1409 1410 ### Parameters 1411 1412 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 1413 the job file during submission). This is specified as part of the path. 1414 1415 - `all` `(bool: false)` - Specifies whether the list of deployments should 1416 include deployments from a previously registered job with the same ID. This is 1417 possible if the job is deregistered and reregistered. 1418 1419 ### Sample Request 1420 1421 ```shell-session 1422 $ curl \ 1423 https://localhost:4646/v1/job/my-job/deployments 1424 ``` 1425 1426 ### Sample Response 1427 1428 ```json 1429 [ 1430 { 1431 "ID": "85ee4a9a-339f-a921-a9ef-0550d20b2c61", 1432 "JobID": "my-job", 1433 "JobVersion": 1, 1434 "JobModifyIndex": 19, 1435 "JobCreateIndex": 7, 1436 "TaskGroups": { 1437 "cache": { 1438 "AutoRevert": true, 1439 "Promoted": false, 1440 "PlacedCanaries": [ 1441 "d0ad0808-2765-abf6-1e15-79fb7fe5a416", 1442 "38c70cd8-81f2-1489-a328-87bb29ec0e0f" 1443 ], 1444 "DesiredCanaries": 2, 1445 "DesiredTotal": 3, 1446 "PlacedAllocs": 2, 1447 "HealthyAllocs": 2, 1448 "UnhealthyAllocs": 0 1449 } 1450 }, 1451 "Status": "running", 1452 "StatusDescription": "Deployment is running", 1453 "CreateIndex": 21, 1454 "ModifyIndex": 25 1455 }, 1456 { 1457 "ID": "fb6070fb-4a44-e255-4e6f-8213eba3871a", 1458 "JobID": "my-job", 1459 "JobVersion": 0, 1460 "JobModifyIndex": 7, 1461 "JobCreateIndex": 7, 1462 "TaskGroups": { 1463 "cache": { 1464 "AutoRevert": true, 1465 "Promoted": false, 1466 "PlacedCanaries": null, 1467 "DesiredCanaries": 0, 1468 "DesiredTotal": 3, 1469 "PlacedAllocs": 3, 1470 "HealthyAllocs": 3, 1471 "UnhealthyAllocs": 0 1472 } 1473 }, 1474 "Status": "successful", 1475 "StatusDescription": "Deployment completed successfully", 1476 "CreateIndex": 9, 1477 "ModifyIndex": 17 1478 } 1479 ] 1480 ``` 1481 1482 ## Read Job's Most Recent Deployment 1483 1484 This endpoint returns a single job's most recent deployment. 1485 1486 | Method | Path | Produces | 1487 | ------ | ---------------------------- | ------------------ | 1488 | `GET` | `/v1/job/:job_id/deployment` | `application/json` | 1489 1490 The table below shows this endpoint's support for 1491 [blocking queries](/api-docs#blocking-queries) and 1492 [required ACLs](/api-docs#acls). 1493 1494 | Blocking Queries | ACL Required | 1495 | ---------------- | -------------------- | 1496 | `YES` | `namespace:read-job` | 1497 1498 ### Parameters 1499 1500 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 1501 the job file during submission). This is specified as part of the path. 1502 1503 ### Sample Request 1504 1505 ```shell-session 1506 $ curl \ 1507 https://localhost:4646/v1/job/my-job/deployment 1508 ``` 1509 1510 ### Sample Response 1511 1512 ```json 1513 { 1514 "ID": "85ee4a9a-339f-a921-a9ef-0550d20b2c61", 1515 "JobID": "my-job", 1516 "JobVersion": 1, 1517 "JobModifyIndex": 19, 1518 "JobCreateIndex": 7, 1519 "TaskGroups": { 1520 "cache": { 1521 "AutoRevert": true, 1522 "Promoted": false, 1523 "PlacedCanaries": [ 1524 "d0ad0808-2765-abf6-1e15-79fb7fe5a416", 1525 "38c70cd8-81f2-1489-a328-87bb29ec0e0f" 1526 ], 1527 "DesiredCanaries": 2, 1528 "DesiredTotal": 3, 1529 "PlacedAllocs": 2, 1530 "HealthyAllocs": 2, 1531 "UnhealthyAllocs": 0 1532 } 1533 }, 1534 "Status": "running", 1535 "StatusDescription": "Deployment is running", 1536 "CreateIndex": 21, 1537 "ModifyIndex": 25 1538 } 1539 ``` 1540 1541 ## Read Job Summary 1542 1543 This endpoint reads summary information about a job. 1544 1545 | Method | Path | Produces | 1546 | ------ | ------------------------- | ------------------ | 1547 | `GET` | `/v1/job/:job_id/summary` | `application/json` | 1548 1549 The table below shows this endpoint's support for 1550 [blocking queries](/api-docs#blocking-queries) and 1551 [required ACLs](/api-docs#acls). 1552 1553 | Blocking Queries | ACL Required | 1554 | ---------------- | -------------------- | 1555 | `YES` | `namespace:read-job` | 1556 1557 ### Parameters 1558 1559 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 1560 the job file during submission). This is specified as part of the path. 1561 1562 ### Sample Request 1563 1564 ```shell-session 1565 $ curl \ 1566 https://localhost:4646/v1/job/my-job/summary 1567 ``` 1568 1569 ### Sample Response 1570 1571 ```json 1572 { 1573 "JobID": "example", 1574 "Summary": { 1575 "cache": { 1576 "Queued": 0, 1577 "Complete": 0, 1578 "Failed": 0, 1579 "Running": 1, 1580 "Starting": 0, 1581 "Lost": 0 1582 } 1583 }, 1584 "Children": { 1585 "Pending": 0, 1586 "Running": 0, 1587 "Dead": 0 1588 }, 1589 "CreateIndex": 7, 1590 "ModifyIndex": 13 1591 } 1592 ``` 1593 1594 ## Update Existing Job 1595 1596 This endpoint registers a new job or updates an existing job. 1597 1598 | Method | Path | Produces | 1599 | ------ | ----------------- | ------------------ | 1600 | `POST` | `/v1/job/:job_id` | `application/json` | 1601 1602 The table below shows this endpoint's support for 1603 [blocking queries](/api-docs#blocking-queries) and 1604 [required ACLs](/api-docs#acls). 1605 1606 | Blocking Queries | ACL Required | 1607 | ---------------- | --------------------------------------------------------------------------------- | 1608 | `NO` | `namespace:submit-job`<br />`namespace:sentinel-override` if `PolicyOverride` set | 1609 1610 ### Parameters 1611 1612 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 1613 the job file during submission). This is specified as part of the path. 1614 1615 - `Job` `(Job: <required>)` - Specifies the JSON definition of the job. 1616 1617 - `EnforceIndex` `(bool: false)` - If set, the job will only be registered if the 1618 passed `JobModifyIndex` matches the current job's index. If the index is zero, 1619 the register only occurs if the job is new. This paradigm allows check-and-set 1620 style job updating. 1621 1622 - `JobModifyIndex` `(int: 0)` - Specifies the `JobModifyIndex` to enforce the 1623 current job is at. 1624 1625 - `PolicyOverride` `(bool: false)` - If set, any soft mandatory Sentinel policies 1626 will be overridden. This allows a job to be registered when it would be denied 1627 by policy. 1628 1629 ### Sample Payload 1630 1631 ```javascript 1632 { 1633 "Job": { 1634 // ... 1635 }, 1636 "EnforceIndex": true, 1637 "JobModifyIndex": 4 1638 } 1639 ``` 1640 1641 ### Sample Request 1642 1643 ```shell-session 1644 $ curl \ 1645 --request POST \ 1646 --data @payload.json \ 1647 https://localhost:4646/v1/job/my-job 1648 ``` 1649 1650 ### Sample Response 1651 1652 ```json 1653 { 1654 "EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac", 1655 "EvalCreateIndex": 35, 1656 "JobModifyIndex": 34 1657 } 1658 ``` 1659 1660 ## Dispatch Job 1661 1662 This endpoint dispatches a new instance of a parameterized job. 1663 1664 | Method | Path | Produces | 1665 | ------ | -------------------------- | ------------------ | 1666 | `POST` | `/v1/job/:job_id/dispatch` | `application/json` | 1667 1668 The table below shows this endpoint's support for 1669 [blocking queries](/api-docs#blocking-queries) and 1670 [required ACLs](/api-docs#acls). 1671 1672 | Blocking Queries | ACL Required | 1673 | ---------------- | ------------------------ | 1674 | `NO` | `namespace:dispatch-job` | 1675 1676 ### Parameters 1677 1678 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified 1679 in the job file during submission). This is specified as part of the path. 1680 1681 - `Payload` `(string: "")` - Specifies a base64 encoded string containing the 1682 payload. This is limited to 16384 bytes (16KiB). 1683 1684 - `Meta` `(meta<string|string>: nil)` - Specifies arbitrary metadata to pass to 1685 the job. 1686 1687 ### Sample Payload 1688 1689 ```json 1690 { 1691 "Payload": "A28C3==", 1692 "Meta": { 1693 "key": "Value" 1694 } 1695 } 1696 ``` 1697 1698 ### Sample Request 1699 1700 ```shell-session 1701 $ curl \ 1702 --request POST \ 1703 --data @payload.json \ 1704 https://localhost:4646/v1/job/my-job/dispatch 1705 ``` 1706 1707 ### Sample Response 1708 1709 ```json 1710 { 1711 "Index": 13, 1712 "JobCreateIndex": 12, 1713 "EvalCreateIndex": 13, 1714 "EvalID": "e5f55fac-bc69-119d-528a-1fc7ade5e02c", 1715 "DispatchedJobID": "example/dispatch-1485408778-81644024" 1716 } 1717 ``` 1718 1719 ## Revert to older Job Version 1720 1721 This endpoint reverts the job to an older version. 1722 1723 | Method | Path | Produces | 1724 | ------ | ------------------------ | ------------------ | 1725 | `POST` | `/v1/job/:job_id/revert` | `application/json` | 1726 1727 The table below shows this endpoint's support for 1728 [blocking queries](/api-docs#blocking-queries) and 1729 [required ACLs](/api-docs#acls). 1730 1731 | Blocking Queries | ACL Required | 1732 | ---------------- | ---------------------- | 1733 | `NO` | `namespace:submit-job` | 1734 1735 ### Parameters 1736 1737 - `JobID` `(string: <required>)` - Specifies the ID of the job (as specified 1738 in the job file during submission). This is specified as part of the path. 1739 1740 - `JobVersion` `(integer: 0)` - Specifies the job version to revert to. 1741 1742 - `EnforcePriorVersion` `(integer: nil)` - Optional value specifying the current 1743 job's version. This is checked and acts as a check-and-set value before 1744 reverting to the specified job. 1745 1746 - `ConsulToken` `(string:"")` - Optional value specifying the [consul token](/docs/commands/job/revert) 1747 used for Consul [service identity polity authentication checking](/docs/configuration/consul#allow_unauthenticated). 1748 1749 - `VaultToken` `(string: "")` - Optional value specifying the [vault token](/docs/commands/job/revert) 1750 used for Vault [policy authentication checking](/docs/configuration/vault#allow_unauthenticated). 1751 1752 ### Sample Payload 1753 1754 ```json 1755 { 1756 "JobID": "my-job", 1757 "JobVersion": 2 1758 } 1759 ``` 1760 1761 ### Sample Request 1762 1763 ```shell-session 1764 $ curl \ 1765 --request POST \ 1766 --data @payload.json \ 1767 https://localhost:4646/v1/job/my-job/revert 1768 ``` 1769 1770 ### Sample Response 1771 1772 ```json 1773 { 1774 "EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac", 1775 "EvalCreateIndex": 35, 1776 "JobModifyIndex": 34 1777 } 1778 ``` 1779 1780 ## Set Job Stability 1781 1782 This endpoint sets the job's stability. 1783 1784 | Method | Path | Produces | 1785 | ------ | ------------------------ | ------------------ | 1786 | `POST` | `/v1/job/:job_id/stable` | `application/json` | 1787 1788 The table below shows this endpoint's support for 1789 [blocking queries](/api-docs#blocking-queries) and 1790 [required ACLs](/api-docs#acls). 1791 1792 | Blocking Queries | ACL Required | 1793 | ---------------- | ---------------------- | 1794 | `NO` | `namespace:submit-job` | 1795 1796 ### Parameters 1797 1798 - `JobID` `(string: <required>)` - Specifies the ID of the job (as specified 1799 in the job file during submission). This is specified as part of the path. 1800 1801 - `JobVersion` `(integer: 0)` - Specifies the job version to set the stability on. 1802 1803 - `Stable` `(bool: false)` - Specifies whether the job should be marked as 1804 stable or not. 1805 1806 ### Sample Payload 1807 1808 ```json 1809 { 1810 "JobID": "my-job", 1811 "JobVersion": 2, 1812 "Stable": true 1813 } 1814 ``` 1815 1816 ### Sample Request 1817 1818 ```shell-session 1819 $ curl \ 1820 --request POST \ 1821 --data @payload.json \ 1822 https://localhost:4646/v1/job/my-job/stable 1823 ``` 1824 1825 ### Sample Response 1826 1827 ```json 1828 { 1829 "JobModifyIndex": 34 1830 } 1831 ``` 1832 1833 ## Create Job Evaluation 1834 1835 This endpoint creates a new evaluation for the given job. This can be used to 1836 force run the scheduling logic if necessary. Since Nomad 0.8.4, this endpoint 1837 supports a JSON payload with additional options. Support for calling this end point 1838 without a JSON payload will be removed in Nomad 0.9. 1839 1840 | Method | Path | Produces | 1841 | ------ | -------------------------- | ------------------ | 1842 | `POST` | `/v1/job/:job_id/evaluate` | `application/json` | 1843 1844 The table below shows this endpoint's support for 1845 [blocking queries](/api-docs#blocking-queries) and 1846 [required ACLs](/api-docs#acls). 1847 1848 | Blocking Queries | ACL Required | 1849 | ---------------- | -------------------- | 1850 | `NO` | `namespace:read-job` | 1851 1852 ### Parameters 1853 1854 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 1855 the job file during submission). This is specified as part of the path. 1856 1857 - `JobID` `(string: <required>)` - Specify the ID of the job in the JSON payload 1858 1859 - `EvalOptions` `(<optional>)` - Specify additional options to be used during the forced evaluation. 1860 - `ForceReschedule` `(bool: false)` - If set, failed allocations of the job are rescheduled 1861 immediately. This is useful for operators to force immediate placement even if the failed allocations are past 1862 their reschedule limit, or are delayed by several hours because the allocation's reschedule policy has exponential delay. 1863 1864 ### Sample Payload 1865 1866 ```json 1867 { 1868 "JobID": "my-job", 1869 "EvalOptions": { 1870 "ForceReschedule": true 1871 } 1872 } 1873 ``` 1874 1875 ### Sample Request 1876 1877 ```shell-session 1878 $ curl \ 1879 --request POST \ 1880 -d @sample.json \ 1881 https://localhost:4646/v1/job/my-job/evaluate 1882 ``` 1883 1884 ### Sample Response 1885 1886 ```json 1887 { 1888 "EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac", 1889 "EvalCreateIndex": 35, 1890 "JobModifyIndex": 34 1891 } 1892 ``` 1893 1894 ## Create Job Plan 1895 1896 This endpoint invokes a dry-run of the scheduler for the job. 1897 1898 | Method | Path | Produces | 1899 | ------ | ---------------------- | ------------------ | 1900 | `POST` | `/v1/job/:job_id/plan` | `application/json` | 1901 1902 The table below shows this endpoint's support for 1903 [blocking queries](/api-docs#blocking-queries) and 1904 [required ACLs](/api-docs#acls). 1905 1906 | Blocking Queries | ACL Required | 1907 | ---------------- | --------------------------------------------------------------------------------- | 1908 | `NO` | `namespace:submit-job`<br />`namespace:sentinel-override` if `PolicyOverride` set | 1909 1910 ### Parameters 1911 1912 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 1913 - the job file during submission). This is specified as part of the path. 1914 1915 - `Job` `(string: <required>)` - Specifies the JSON definition of the job. 1916 1917 - `Diff` `(bool: false)` - Specifies whether the diff structure between the 1918 submitted and server side version of the job should be included in the 1919 response. 1920 1921 - `PolicyOverride` `(bool: false)` - If set, any soft mandatory Sentinel policies 1922 will be overridden. This allows a job to be registered when it would be denied 1923 by policy. 1924 1925 ### Sample Payload 1926 1927 ```json 1928 { 1929 "Job": { 1930 // ... 1931 }, 1932 "Diff": true, 1933 "PolicyOverride": false 1934 } 1935 ``` 1936 1937 ### Sample Request 1938 1939 ```shell-session 1940 $ curl \ 1941 --request POST \ 1942 --data @payload.json \ 1943 https://localhost:4646/v1/job/my-job/plan 1944 ``` 1945 1946 ### Sample Response 1947 1948 ```json 1949 { 1950 "Index": 0, 1951 "NextPeriodicLaunch": "0001-01-01T00:00:00Z", 1952 "Warnings": "", 1953 "Diff": { 1954 "Type": "Added", 1955 "TaskGroups": [ 1956 { 1957 "Updates": { 1958 "create": 1 1959 }, 1960 "Type": "Added", 1961 "Tasks": [ 1962 { 1963 "Type": "Added", 1964 "Objects": ["..."], 1965 "Name": "redis", 1966 "Fields": [ 1967 { 1968 "Type": "Added", 1969 "Old": "", 1970 "New": "docker", 1971 "Name": "Driver", 1972 "Annotations": null 1973 }, 1974 { 1975 "Type": "Added", 1976 "Old": "", 1977 "New": "5000000000", 1978 "Name": "KillTimeout", 1979 "Annotations": null 1980 } 1981 ], 1982 "Annotations": ["forces create"] 1983 } 1984 ], 1985 "Objects": ["..."], 1986 "Name": "cache", 1987 "Fields": ["..."] 1988 } 1989 ], 1990 "Objects": [ 1991 { 1992 "Type": "Added", 1993 "Objects": null, 1994 "Name": "Datacenters", 1995 "Fields": ["..."] 1996 }, 1997 { 1998 "Type": "Added", 1999 "Objects": null, 2000 "Name": "Constraint", 2001 "Fields": ["..."] 2002 }, 2003 { 2004 "Type": "Added", 2005 "Objects": null, 2006 "Name": "Update", 2007 "Fields": ["..."] 2008 } 2009 ], 2010 "ID": "example", 2011 "Fields": ["..."] 2012 }, 2013 "CreatedEvals": [ 2014 { 2015 "ModifyIndex": 0, 2016 "CreateIndex": 0, 2017 "SnapshotIndex": 0, 2018 "AnnotatePlan": false, 2019 "EscapedComputedClass": false, 2020 "NodeModifyIndex": 0, 2021 "NodeID": "", 2022 "JobModifyIndex": 0, 2023 "JobID": "example", 2024 "TriggeredBy": "job-register", 2025 "Type": "batch", 2026 "Priority": 50, 2027 "ID": "312e6a6d-8d01-0daf-9105-14919a66dba3", 2028 "Status": "blocked", 2029 "StatusDescription": "created to place remaining allocations", 2030 "Wait": 0, 2031 "NextEval": "", 2032 "PreviousEval": "80318ae4-7eda-e570-e59d-bc11df134817", 2033 "BlockedEval": "", 2034 "FailedTGAllocs": null, 2035 "ClassEligibility": { 2036 "v1:7968290453076422024": true 2037 } 2038 } 2039 ], 2040 "JobModifyIndex": 0, 2041 "FailedTGAllocs": { 2042 "cache": { 2043 "CoalescedFailures": 3, 2044 "AllocationTime": 46415, 2045 "Scores": null, 2046 "NodesEvaluated": 1, 2047 "NodesFiltered": 0, 2048 "NodesAvailable": { 2049 "dc1": 1 2050 }, 2051 "ClassFiltered": null, 2052 "ConstraintFiltered": null, 2053 "NodesExhausted": 1, 2054 "ClassExhausted": null, 2055 "DimensionExhausted": { 2056 "cpu": 1 2057 } 2058 } 2059 }, 2060 "Annotations": { 2061 "DesiredTGUpdates": { 2062 "cache": { 2063 "DestructiveUpdate": 0, 2064 "InPlaceUpdate": 0, 2065 "Stop": 0, 2066 "Migrate": 0, 2067 "Place": 11, 2068 "Ignore": 0 2069 } 2070 } 2071 } 2072 } 2073 ``` 2074 2075 #### Field Reference 2076 2077 - `Diff` - A diff structure between the submitted job and the server side 2078 version. The top-level object is a Job Diff which contains Task Group Diffs, 2079 which in turn contain Task Diffs. Each of these objects then has Object and 2080 Field Diff structures embedded. 2081 2082 - `NextPeriodicLaunch` - If the job being planned is periodic, this field will 2083 include the next launch time for the job. 2084 2085 - `CreatedEvals` - A set of evaluations that were created as a result of the 2086 dry-run. These evaluations can signify a follow-up rolling update evaluation 2087 or a blocked evaluation. 2088 2089 - `JobModifyIndex` - The `JobModifyIndex` of the server side version of this job. 2090 2091 - `FailedTGAllocs` - A set of metrics to understand any allocation failures that 2092 occurred for the Task Group. 2093 2094 - `Annotations` - Annotations include the `DesiredTGUpdates`, which tracks what 2095 - the scheduler would do given enough resources for each Task Group. 2096 2097 ## Force New Periodic Instance 2098 2099 This endpoint forces a new instance of the periodic job. A new instance will be 2100 created even if it violates the job's 2101 [`prohibit_overlap`](/docs/job-specification/periodic#prohibit_overlap) 2102 settings. As such, this should be only used to immediately run a periodic job. 2103 2104 | Method | Path | Produces | 2105 | ------ | -------------------------------- | ------------------ | 2106 | `POST` | `/v1/job/:job_id/periodic/force` | `application/json` | 2107 2108 The table below shows this endpoint's support for 2109 [blocking queries](/api-docs#blocking-queries) and 2110 [required ACLs](/api-docs#acls). 2111 2112 | Blocking Queries | ACL Required | 2113 | ---------------- | -------------------------------------------------- | 2114 | `NO` | `namespace:dispatch-job` or `namespace:submit-job` | 2115 2116 ### Parameters 2117 2118 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 2119 the job file during submission). This is specified as part of the path. 2120 2121 ### Sample Request 2122 2123 ```shell-session 2124 $ curl \ 2125 --request POST \ 2126 https://localhost:4646/v1/job/my-job/periodic/force 2127 ``` 2128 2129 ### Sample Response 2130 2131 ```json 2132 { 2133 "EvalCreateIndex": 7, 2134 "EvalID": "57983ddd-7fcf-3e3a-fd24-f699ccfb36f4" 2135 } 2136 ``` 2137 2138 ## Stop a Job 2139 2140 This endpoint deregisters a job, and stops all allocations part of it. 2141 2142 | Method | Path | Produces | 2143 | -------- | ----------------- | ------------------ | 2144 | `DELETE` | `/v1/job/:job_id` | `application/json` | 2145 2146 The table below shows this endpoint's support for 2147 [blocking queries](/api-docs#blocking-queries) and 2148 [required ACLs](/api-docs#acls). 2149 2150 | Blocking Queries | ACL Required | 2151 | ---------------- | ---------------------- | 2152 | `NO` | `namespace:submit-job` | 2153 2154 ### Parameters 2155 2156 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 2157 the job file during submission). This is specified as part of the path. 2158 2159 - `purge` `(bool: false)` - Specifies that the job should stopped and purged 2160 immediately. This means the job will not be queryable after being stopped. If 2161 not set, the job will be purged by the garbage collector. 2162 2163 ### Sample Request 2164 2165 ```shell-session 2166 $ curl \ 2167 --request DELETE \ 2168 https://localhost:4646/v1/job/my-job?purge=true 2169 ``` 2170 2171 ### Sample Response 2172 2173 ```json 2174 { 2175 "EvalID": "d092fdc0-e1fd-2536-67d8-43af8ca798ac", 2176 "EvalCreateIndex": 35, 2177 "JobModifyIndex": 34 2178 } 2179 ``` 2180 2181 ## Read Job Scale Status 2182 2183 This endpoint reads scale information about a job. 2184 2185 | Method | Path | Produces | 2186 | ------ | ----------------------- | ------------------ | 2187 | `GET` | `/v1/job/:job_id/scale` | `application/json` | 2188 2189 The table below shows this endpoint's support for 2190 [blocking queries](/api-docs#blocking-queries) and 2191 [required ACLs](/api-docs#acls). 2192 2193 | Blocking Queries | ACL Required | 2194 | ---------------- | ---------------------------------------------------- | 2195 | `YES` | `namespace:read-job-scaling` or `namespace:read-job` | 2196 2197 ### Parameters 2198 2199 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 2200 the job file during submission). This is specified as part of the path. 2201 2202 ### Sample Request 2203 2204 ```shell-session 2205 $ curl \ 2206 https://localhost:4646/v1/job/my-job/scale 2207 ``` 2208 2209 ### Sample Response 2210 2211 ```json 2212 { 2213 "JobCreateIndex": 10, 2214 "JobID": "example", 2215 "Namespace": "default", 2216 "JobModifyIndex": 18, 2217 "JobStopped": false, 2218 "TaskGroups": { 2219 "cache": { 2220 "Desired": 1, 2221 "Events": null, 2222 "Healthy": 1, 2223 "Placed": 1, 2224 "Running": 0, 2225 "Unhealthy": 0 2226 } 2227 } 2228 } 2229 ``` 2230 2231 ## Scale Task Group 2232 2233 This endpoint performs a scaling action against a job. 2234 Currently, this endpoint supports scaling the count for a task group. 2235 This will return a 400 error if the job has an active deployment. 2236 2237 | Method | Path | Produces | 2238 | ------ | ----------------------- | ------------------ | 2239 | `POST` | `/v1/job/:job_id/scale` | `application/json` | 2240 2241 The table below shows this endpoint's support for 2242 [blocking queries](/api-docs#blocking-queries) and 2243 [required ACLs](/api-docs#acls). 2244 2245 | Blocking Queries | ACL Required | 2246 | ---------------- | ---------------------------------------------------------------------------------------------------------- | 2247 | `NO` | `namespace:scale-job` or `namespace:submit-job`<br />`namespace:sentinel-override` if `PolicyOverride` set | 2248 2249 ### Parameters 2250 2251 - `:job_id` `(string: <required>)` - Specifies the ID of the job (as specified in 2252 the job file during submission). This is specified as part of the path. 2253 2254 - `Count` `(int: <optional>)` - Specifies the new task group count. 2255 2256 - `Target` `(json: required)` - JSON map containing the target of the scaling operation. 2257 Must contain a field `Group` with the name of the task group that is the target of this scaling action. 2258 2259 - `Message` `(string: <optional>)` - Description of the scale action, persisted as part of the scaling event. 2260 Indicates information or reason for scaling; one of `Message` or `Error` must be provided. 2261 2262 - `Error` `(string: <optional>)` - Description of the scale action, persisted as part of the scaling event. 2263 Indicates an error state preventing scaling; one of `Message` or `Error` must be provided. 2264 2265 - `Meta` `(json: <optional>)` - JSON block that is persisted as part of the scaling event. 2266 2267 - `PolicyOverride` `(bool: false)` - If set, any soft mandatory Sentinel policies 2268 will be overridden. This allows a job to be scaled when it would be denied 2269 by policy. 2270 2271 ### Sample Payload 2272 2273 ```javascript 2274 { 2275 "Count": 5, 2276 "Meta": { 2277 "metrics": [ 2278 "cpu", 2279 "memory" 2280 ] 2281 }, 2282 "Message": "metric did not satisfy SLA", 2283 "Target": { 2284 "Group": "cache" 2285 } 2286 } 2287 ``` 2288 2289 ### Sample Request 2290 2291 ```shell-session 2292 $ curl \ 2293 --request POST \ 2294 --data @payload.json \ 2295 https://localhost:4646/v1/job/example/scale 2296 ``` 2297 2298 ### Sample Response 2299 2300 This is the same payload as returned by job update. 2301 `EvalCreateIndex` and `EvalID` will only be present if the scaling operation resulted in the creation of an evaluation. 2302 2303 ```json 2304 { 2305 "EvalCreateIndex": 45, 2306 "EvalID": "116f3ede-f6a5-f6e7-2d0e-1fda136390f0", 2307 "Index": 45, 2308 "JobModifyIndex": 44, 2309 "KnownLeader": false, 2310 "LastContact": 0, 2311 "Warnings": "" 2312 } 2313 ```