From c3a37668dcd089c9004c9095b1d853694a67f993 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Tue, 17 Nov 2015 19:12:19 -0800 Subject: [PATCH] Update API docs --- client/driver/docker.go | 10 +- website/source/docs/http/alloc.html.md | 297 ++++++++++++---------- website/source/docs/http/allocs.html.md | 42 +++- website/source/docs/http/job.html.md | 2 +- website/source/docs/http/node.html.md | 313 ++++++++++++++---------- 5 files changed, 395 insertions(+), 269 deletions(-) diff --git a/client/driver/docker.go b/client/driver/docker.go index f4bdc5f15..3ee70713f 100644 --- a/client/driver/docker.go +++ b/client/driver/docker.go @@ -269,8 +269,14 @@ func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task, dri containerToHostPortMap := make(map[string]int) for _, port := range network.DynamicPorts { - containerPort, ok := driverConfig.PortMap[0][port.Label] - if !ok { + var containerPort int + if len(driverConfig.PortMap) > 0 { + var ok bool + containerPort, ok = driverConfig.PortMap[0][port.Label] + if !ok { + containerPort = port.Value + } + } else { containerPort = port.Value } diff --git a/website/source/docs/http/alloc.html.md b/website/source/docs/http/alloc.html.md index 822858a8c..00776b606 100644 --- a/website/source/docs/http/alloc.html.md +++ b/website/source/docs/http/alloc.html.md @@ -41,144 +41,193 @@ be specified using the `?region=` query parameter. ```javascript { - "ID": "3575ba9d-7a12-0c96-7b28-add168c67984", - "EvalID": "151accaa-1ac6-90fe-d427-313e70ccbb88", - "Name": "binstore-storagelocker.binsl[3]", - "NodeID": "", - "JobID": "binstore-storagelocker", - "Job": { + "ID": "203266e5-e0d6-9486-5e05-397ed2b184af", + "EvalID": "e68125ed-3fba-fb46-46cc-291addbc4455", + "Name": "example.cache[0]", + "NodeID": "e02b6169-83bd-9df6-69bd-832765f333eb", + "JobID": "example", + "ModifyIndex": 9, + "Resources": { + "Networks": [ + { + "DynamicPorts": [ + { + "Value": 20802, + "Label": "db" + } + ], + "ReservedPorts": null, + "MBits": 10, + "IP": "", + "CIDR": "", + "Device": "" + } + ], + "IOPS": 0, + "DiskMB": 0, + "MemoryMB": 256, + "CPU": 500 + }, + "TaskGroup": "cache", + "Job": { + "ModifyIndex": 5, + "CreateIndex": 5, + "StatusDescription": "", + "Status": "", + "Meta": null, + "Update": { + "MaxParallel": 1, + "Stagger": 1e+10 + }, + "TaskGroups": [ + { + "Meta": null, + "Tasks": [ + { + "Meta": null, + "Resources": { + "Networks": [ + { + "DynamicPorts": [ + { + "Value": 20802, + "Label": "db" + } + ], + "ReservedPorts": null, + "MBits": 0, + "IP": "127.0.0.1", + "CIDR": "", + "Device": "lo" + } + ], + "IOPS": 0, + "DiskMB": 0, + "MemoryMB": 256, + "CPU": 500 + }, + "Constraints": null, + "Services": [ + { + "Checks": [ + { + "Timeout": 2e+09, + "Interval": 1e+10, + "Protocol": "", + "Http": "", + "Script": "", + "Type": "tcp", + "Name": "alive", + "Id": "" + } + ], + "PortLabel": "db", + "Tags": [ + "global", + "cache" + ], + "Name": "example-cache-redis", + "Id": "" + } + ], + "Env": null, + "Config": { + "port_map": [ + { + "db": 6379 + } + ], + "image": "redis:latest" + }, + "Driver": "docker", + "Name": "redis" + } + ], + "RestartPolicy": { + "Delay": 2.5e+10, + "Interval": 3e+11, + "Attempts": 10 + }, + "Constraints": null, + "Count": 1, + "Name": "cache" + } + ], "Region": "global", - "ID": "binstore-storagelocker", - "Name": "binstore-storagelocker", + "ID": "example", + "Name": "example", "Type": "service", "Priority": 50, "AllAtOnce": false, "Datacenters": [ - "us2", - "eu1" + "dc1" ], "Constraints": [ - { - "LTarget": "kernel.os", - "RTarget": "windows", - "Operand": "=", - } - ], - "TaskGroups": [ - { - "Name": "binsl", - "Count": 5, - "Constraints": [ - { - "LTarget": "kernel.os", - "RTarget": "linux", - "Operand": "=", - } - ], - "Tasks": [ - { - "Name": "binstore", - "Driver": "docker", - "Config": { - "image": "hashicorp/binstore" - }, - "Constraints": null, - "Resources": { - "CPU": 500, - "MemoryMB": 0, - "DiskMB": 0, - "IOPS": 0, - "Networks": [ - { - "Device": "", - "CIDR": "", - "IP": "", - "MBits": 100, - "ReservedPorts": null, - "DynamicPorts": 0 - } - ] - }, - "Meta": null - }, - { - "Name": "storagelocker", - "Driver": "java", - "Config": { - "image": "hashicorp/storagelocker" - }, - "Constraints": [ - { - "LTarget": "kernel.arch", - "RTarget": "amd64", - "Operand": "=", - } - ], - "Resources": { - "CPU": 500, - "MemoryMB": 0, - "DiskMB": 0, - "IOPS": 0, - "Networks": null - }, - "Meta": null - } - ], - "Meta": { - "elb_checks": "3", - "elb_interval": "10", - "elb_mode": "tcp" - } - } - ], - "Update": { - "Stagger": 0, - "MaxParallel": 0 - }, - "Meta": { - "foo": "bar" - }, - "Status": "", - "StatusDescription": "", - "CreateIndex": 14, - "ModifyIndex": 14 - }, - "TaskGroup": "binsl", - "Resources": { - "CPU": 1000, - "MemoryMB": 0, - "DiskMB": 0, - "IOPS": 0, - "Networks": [ - { - "Device": "", - "CIDR": "", - "IP": "", - "MBits": 100, - "ReservedPorts": null, - "DynamicPorts": 0 - } + { + "Operand": "=", + "RTarget": "linux", + "LTarget": "$attr.kernel.name" + } ] - }, - "TaskResources": null, - "Metrics": { - "NodesEvaluated": 0, + }, + "TaskResources": { + "redis": { + "Networks": [ + { + "DynamicPorts": [ + { + "Value": 20802, + "Label": "db" + } + ], + "ReservedPorts": null, + "MBits": 0, + "IP": "127.0.0.1", + "CIDR": "", + "Device": "lo" + } + ], + "IOPS": 0, + "DiskMB": 0, + "MemoryMB": 256, + "CPU": 500 + } + }, + "Metrics": { + "CoalescedFailures": 0, + "AllocationTime": 1590406, + "NodesEvaluated": 1, "NodesFiltered": 0, "ClassFiltered": null, "ConstraintFiltered": null, "NodesExhausted": 0, "ClassExhausted": null, "DimensionExhausted": null, - "Scores": null, - "AllocationTime": 9408, - "CoalescedFailures": 4 - }, - "DesiredStatus": "failed", - "DesiredDescription": "failed to find a node for placement", - "ClientStatus": "failed", - "ClientDescription": "", - "CreateIndex": 16, - "ModifyIndex": 16 + "Scores": { + "e02b6169-83bd-9df6-69bd-832765f333eb.binpack": 6.133651487695705 + } + }, + "DesiredStatus": "run", + "DesiredDescription": "", + "ClientStatus": "running", + "ClientDescription": "", + "TaskStates": { + "redis": { + "Events": [ + { + "KillError": "", + "Message": "", + "Signal": 0, + "ExitCode": 0, + "DriverError": "", + "Time": 1447806038427841000, + "Type": "Started" + } + ], + "State": "running" + } + }, + "CreateIndex": 7 } ``` diff --git a/website/source/docs/http/allocs.html.md b/website/source/docs/http/allocs.html.md index b59a4f204..7cb38ab66 100644 --- a/website/source/docs/http/allocs.html.md +++ b/website/source/docs/http/allocs.html.md @@ -42,19 +42,35 @@ be specified using the `?region=` query parameter. ```javascript [ { - "ID": "3575ba9d-7a12-0c96-7b28-add168c67984", - "EvalID": "151accaa-1ac6-90fe-d427-313e70ccbb88", - "Name": "binstore-storagelocker.binsl[3]", - "NodeID": "c9972143-861d-46e6-df73-1d8287bc3e66", - "JobID": "binstore-storagelocker", - "TaskGroup": "binsl", - "DesiredStatus": "run", - "DesiredDescription": "", - "ClientStatus": "running", - "ClientDescription": "", - "CreateIndex": 16, - "ModifyIndex": 16 - }, + "ID": "203266e5-e0d6-9486-5e05-397ed2b184af", + "EvalID": "e68125ed-3fba-fb46-46cc-291addbc4455", + "Name": "example.cache[0]", + "NodeID": "e02b6169-83bd-9df6-69bd-832765f333eb", + "JobID": "example", + "TaskGroup": "cache", + "DesiredStatus": "run", + "DesiredDescription": "" + "ClientDescription": "", + "ClientStatus": "running", + "TaskStates": { + "redis": { + "Events": [ + { + "KillError": "", + "Message": "", + "Signal": 0, + "ExitCode": 0, + "DriverError": "", + "Time": 1447806038427841000, + "Type": "Started" + } + ], + "State": "running" + } + }, + "CreateIndex": 7, + "ModifyIndex": 9, + } ... ] ``` diff --git a/website/source/docs/http/job.html.md b/website/source/docs/http/job.html.md index cbf0f5097..05484aec9 100644 --- a/website/source/docs/http/job.html.md +++ b/website/source/docs/http/job.html.md @@ -88,7 +88,7 @@ region is used; another region can be specified using the `?region=` query param "IP": "", "MBits": 100, "ReservedPorts": null, - "DynamicPorts": 0 + "DynamicPorts": null } ] }, diff --git a/website/source/docs/http/node.html.md b/website/source/docs/http/node.html.md index ed69d96e9..794e0283a 100644 --- a/website/source/docs/http/node.html.md +++ b/website/source/docs/http/node.html.md @@ -59,6 +59,7 @@ be specified using the `?region=` query parameter. "kernel.name": "darwin", "kernel.version": "14.4.0", "memory.totalbytes": "8589934592", + "network.ip-address": "127.0.0.1", "os.name": "darwin", "os.version": "14.4.0", "storage.bytesfree": "35888713728", @@ -114,141 +115,195 @@ be specified using the `?region=` query parameter. ```javascript [ - { - "ID": "8a0c24d9-cdfc-ce67-1208-8d4524b1a9b3", - "EvalID": "2c699410-8697-6109-86b7-430909b00bb9", - "Name": "example.cache[0]", - "NodeID": "12d3409b-9d27-fcad-a03d-b3c18887d153", - "JobID": "example", - "Job": { - "Region": "global", - "ID": "example", - "Name": "example", - "Type": "service", - "Priority": 50, - "AllAtOnce": false, - "Datacenters": [ - "lon1" - ], - "Constraints": [ - { - "Hard": true, - "LTarget": "$attr.kernel.name", - "RTarget": "linux", - "Operand": "=", - "Weight": 0 - } - ], - "TaskGroups": [ - { - "Name": "cache", - "Count": 1, - "Constraints": null, - "Tasks": [ - { - "Name": "redis", - "Driver": "docker", - "Config": { - "image": "redis:latest" - }, - "Env": null, - "Constraints": null, - "Resources": { - "CPU": 500, - "MemoryMB": 256, - "DiskMB": 0, - "IOPS": 0, - "Networks": [ - { - "Device": "", - "CIDR": "", - "IP": "", - "MBits": 10, - "ReservedPorts": null, - "DynamicPorts": [ - "6379" - ] - } - ] - }, - "Meta": null - } - ], - "Meta": null - } - ], - "Update": { - "Stagger": 0, - "MaxParallel": 0 - }, - "Meta": null, - "Status": "", - "StatusDescription": "", - "CreateIndex": 6, - "ModifyIndex": 6 + { + "ID": "203266e5-e0d6-9486-5e05-397ed2b184af", + "EvalID": "e68125ed-3fba-fb46-46cc-291addbc4455", + "Name": "example.cache[0]", + "NodeID": "e02b6169-83bd-9df6-69bd-832765f333eb", + "JobID": "example", + "ModifyIndex": 9, + "Resources": { + "Networks": [ + { + "DynamicPorts": [ + { + "Value": 20802, + "Label": "db" + } + ], + "ReservedPorts": null, + "MBits": 10, + "IP": "", + "CIDR": "", + "Device": "" + } + ], + "IOPS": 0, + "DiskMB": 0, + "MemoryMB": 256, + "CPU": 500 + }, + "TaskGroup": "cache", + "Job": { + "ModifyIndex": 5, + "CreateIndex": 5, + "StatusDescription": "", + "Status": "", + "Meta": null, + "Update": { + "MaxParallel": 1, + "Stagger": 1e+10 }, - "TaskGroup": "cache", - "Resources": { - "CPU": 500, - "MemoryMB": 256, - "DiskMB": 0, - "IOPS": 0, + "TaskGroups": [ + { + "Meta": null, + "Tasks": [ + { + "Meta": null, + "Resources": { + "Networks": [ + { + "DynamicPorts": [ + { + "Value": 20802, + "Label": "db" + } + ], + "ReservedPorts": null, + "MBits": 0, + "IP": "127.0.0.1", + "CIDR": "", + "Device": "lo" + } + ], + "IOPS": 0, + "DiskMB": 0, + "MemoryMB": 256, + "CPU": 500 + }, + "Constraints": null, + "Services": [ + { + "Checks": [ + { + "Timeout": 2e+09, + "Interval": 1e+10, + "Protocol": "", + "Http": "", + "Script": "", + "Type": "tcp", + "Name": "alive", + "Id": "" + } + ], + "PortLabel": "db", + "Tags": [ + "global", + "cache" + ], + "Name": "example-cache-redis", + "Id": "" + } + ], + "Env": null, + "Config": { + "port_map": [ + { + "db": 6379 + } + ], + "image": "redis:latest" + }, + "Driver": "docker", + "Name": "redis" + } + ], + "RestartPolicy": { + "Delay": 2.5e+10, + "Interval": 3e+11, + "Attempts": 10 + }, + "Constraints": null, + "Count": 1, + "Name": "cache" + } + ], + "Region": "global", + "ID": "example", + "Name": "example", + "Type": "service", + "Priority": 50, + "AllAtOnce": false, + "Datacenters": [ + "dc1" + ], + "Constraints": [ + { + "Operand": "=", + "RTarget": "linux", + "LTarget": "$attr.kernel.name" + } + ] + }, + "TaskResources": { + "redis": { "Networks": [ { - "Device": "", - "CIDR": "", - "IP": "", - "MBits": 10, - "ReservedPorts": null, "DynamicPorts": [ - "6379" - ] + { + "Value": 20802, + "Label": "db" + } + ], + "ReservedPorts": null, + "MBits": 0, + "IP": "127.0.0.1", + "CIDR": "", + "Device": "lo" } - ] - }, - "TaskResources": { - "redis": { - "CPU": 500, - "MemoryMB": 256, - "DiskMB": 0, - "IOPS": 0, - "Networks": [ - { - "Device": "eth0", - "CIDR": "", - "IP": "10.16.0.222", - "MBits": 0, - "ReservedPorts": [ - 23889 - ], - "DynamicPorts": [ - "6379" - ] - } - ] - } - }, - "Metrics": { - "NodesEvaluated": 1, - "NodesFiltered": 0, - "ClassFiltered": null, - "ConstraintFiltered": null, - "NodesExhausted": 0, - "ClassExhausted": null, - "DimensionExhausted": null, - "Scores": { - "12d3409b-9d27-fcad-a03d-b3c18887d153.binpack": 10.779215064231561 - }, - "AllocationTime": 75232, - "CoalescedFailures": 0 - }, - "DesiredStatus": "run", - "DesiredDescription": "", - "ClientStatus": "pending", - "ClientDescription": "", - "CreateIndex": 8, - "ModifyIndex": 8 + ], + "IOPS": 0, + "DiskMB": 0, + "MemoryMB": 256, + "CPU": 500 + } }, + "Metrics": { + "CoalescedFailures": 0, + "AllocationTime": 1590406, + "NodesEvaluated": 1, + "NodesFiltered": 0, + "ClassFiltered": null, + "ConstraintFiltered": null, + "NodesExhausted": 0, + "ClassExhausted": null, + "DimensionExhausted": null, + "Scores": { + "e02b6169-83bd-9df6-69bd-832765f333eb.binpack": 6.133651487695705 + } + }, + "DesiredStatus": "run", + "DesiredDescription": "", + "ClientStatus": "running", + "ClientDescription": "", + "TaskStates": { + "redis": { + "Events": [ + { + "KillError": "", + "Message": "", + "Signal": 0, + "ExitCode": 0, + "DriverError": "", + "Time": 1447806038427841000, + "Type": "Started" + } + ], + "State": "running" + } + }, + "CreateIndex": 7 + }, ... ] ```