From 740b0abbff2e1ce4fe4615ef262c8134dc456165 Mon Sep 17 00:00:00 2001 From: Renaud Gaubert Date: Fri, 17 Nov 2017 23:05:59 +0100 Subject: [PATCH] Added support of Generic resources in compose file Signed-off-by: Renaud Gaubert --- cli/command/service/create.go | 2 - cli/compose/convert/service.go | 20 ++++++++- cli/compose/loader/full-example.yml | 10 ++++- cli/compose/loader/loader_test.go | 14 ++++++ cli/compose/schema/bindata.go | 2 +- .../schema/data/config_schema_v3.5.json | 44 ++++++++++++++----- cli/compose/types/types.go | 20 ++++++++- 7 files changed, 93 insertions(+), 19 deletions(-) diff --git a/cli/command/service/create.go b/cli/command/service/create.go index 6e19f8b74808..299cdc383f10 100644 --- a/cli/command/service/create.go +++ b/cli/command/service/create.go @@ -77,8 +77,6 @@ func runCreate(dockerCli command.Cli, flags *pflag.FlagSet, opts *serviceOptions return err } - fmt.Printf("%v\n", service.TaskTemplate.Resources) - specifiedSecrets := opts.secrets.Value() if len(specifiedSecrets) > 0 { // parse and validate secrets diff --git a/cli/compose/convert/service.go b/cli/compose/convert/service.go index e180307047dd..86ad6009e12f 100644 --- a/cli/compose/convert/service.go +++ b/cli/compose/convert/service.go @@ -510,9 +510,25 @@ func convertResources(source composetypes.Resources) (*swarm.ResourceRequirement return nil, err } } + + var generic []swarm.GenericResource + for _, res := range source.Reservations.GenericResources { + var r swarm.GenericResource + + if res.DiscreteResourceSpec != nil { + r.DiscreteResourceSpec = &swarm.DiscreteGenericResource{ + Kind: res.DiscreteResourceSpec.Kind, + Value: res.DiscreteResourceSpec.Value, + } + } + + generic = append(generic, r) + } + resources.Reservations = &swarm.Resources{ - NanoCPUs: cpus, - MemoryBytes: int64(source.Reservations.MemoryBytes), + NanoCPUs: cpus, + MemoryBytes: int64(source.Reservations.MemoryBytes), + GenericResources: generic, } } return resources, nil diff --git a/cli/compose/loader/full-example.yml b/cli/compose/loader/full-example.yml index aefb56869ebb..0a52111c3236 100644 --- a/cli/compose/loader/full-example.yml +++ b/cli/compose/loader/full-example.yml @@ -1,4 +1,4 @@ -version: "3.4" +version: "3.5" services: foo: @@ -16,7 +16,6 @@ services: labels: [FOO=BAR] - cap_add: - ALL @@ -54,6 +53,13 @@ services: reservations: cpus: '0.0001' memory: 20M + generic_resources: + - discrete_resource_spec: + kind: 'gpu' + value: 2 + - discrete_resource_spec: + kind: 'ssd' + value: 1 restart_policy: condition: on-failure delay: 5s diff --git a/cli/compose/loader/loader_test.go b/cli/compose/loader/loader_test.go index bc6f6f475831..a88d0625ecbe 100644 --- a/cli/compose/loader/loader_test.go +++ b/cli/compose/loader/loader_test.go @@ -879,6 +879,20 @@ func TestFullExample(t *testing.T) { Reservations: &types.Resource{ NanoCPUs: "0.0001", MemoryBytes: 20 * 1024 * 1024, + GenericResources: []types.GenericResource{ + { + DiscreteResourceSpec: &types.DiscreteGenericResource{ + Kind: "gpu", + Value: 2, + }, + }, + { + DiscreteResourceSpec: &types.DiscreteGenericResource{ + Kind: "ssd", + Value: 1, + }, + }, + }, }, }, RestartPolicy: &types.RestartPolicy{ diff --git a/cli/compose/schema/bindata.go b/cli/compose/schema/bindata.go index 5f150e13e7c7..2963ed67b9b9 100644 --- a/cli/compose/schema/bindata.go +++ b/cli/compose/schema/bindata.go @@ -173,7 +173,7 @@ func dataConfig_schema_v34Json() (*asset, error) { return a, nil } -var _dataConfig_schema_v35Json = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x5b\xcf\x72\xdb\xbc\x11\xbf\xeb\x29\x38\xfc\xbe\x5b\x24\x3b\x33\x4d\x3b\xd3\xdc\x7a\xec\xa9\x3d\xd7\xa3\x70\x20\x70\x25\x21\x06\x01\x64\x01\xca\x56\x32\x7e\xf7\x0e\xff\x0a\x24\x41\x02\x94\xe8\xd8\x69\x73\xb2\x45\xee\x2e\xb0\x8b\xdd\x1f\x76\x17\xe0\x8f\x55\x14\xc5\x7f\x6a\x7a\x84\x8c\xc4\x9f\xa3\xf8\x68\x8c\xfa\x7c\x7f\xff\x55\x4b\xb1\xa9\x9e\xde\x49\x3c\xdc\xa7\x48\xf6\x66\xf3\xf1\xd3\x7d\xf5\xec\x8f\x78\x5d\xf0\xb1\xb4\x60\xa1\x52\xec\xd9\x21\xa9\xde\x24\xa7\xbf\xdc\xfd\xf5\xae\x60\xaf\x48\xcc\x59\x41\x41\x24\x77\x5f\x81\x9a\xea\x19\xc2\xb7\x9c\x21\x14\xcc\x0f\xf1\x09\x50\x33\x29\xe2\xed\x7a\x55\xbc\x53\x28\x15\xa0\x61\xa0\xe3\xcf\x51\x31\xb9\x28\x6a\x49\x9a\x07\x96\x58\x6d\x90\x89\x43\x5c\x3e\x7e\x29\x25\x44\x51\xac\x01\x4f\x8c\x5a\x12\xda\xa9\xfe\x71\x7f\x91\x7f\xdf\x92\xad\xfb\x52\xad\xc9\x96\xcf\x15\x31\x06\x50\xfc\x7b\x38\xb7\xf2\xf5\x97\x07\xb2\xf9\xfe\x8f\xcd\x7f\x3e\x6e\xfe\x7e\x97\x6c\xb6\x1f\xfe\xec\xbc\x2e\xec\x8b\xb0\xaf\x86\x4f\x61\xcf\x04\x33\x4c\x8a\x76\xfc\xb8\xa5\x7c\xa9\xff\x7b\x69\x07\x26\x69\x5a\x12\x13\xde\x19\x7b\x4f\xb8\x86\xae\xce\x02\xcc\x93\xc4\x47\x9f\xce\x2d\xd9\x1b\xe9\x5c\x8f\xef\xd0\xb9\xab\xce\x49\xf2\x3c\xf3\xae\x60\x43\xf5\x46\xca\x54\xc3\x2f\xb3\x7e\x1a\x28\x82\xf1\xbb\x6c\x45\xf5\x66\x1e\x5b\x0c\xbf\x8c\xc2\x15\x6a\xf8\x14\x6e\xa8\xde\x48\xe1\x6a\xf8\xdb\x14\x5e\x35\x4a\xbb\xe7\x18\x7f\x79\xde\x14\x7f\x5f\x4a\x99\x93\xf2\x2a\x29\xd6\xfc\x4a\x25\x3a\x98\xe7\x32\xa7\x0b\x73\xc6\xed\xd9\x1a\x74\xc4\x92\x29\x28\x2e\xcf\xe5\xcc\xdd\x36\xab\x08\x32\x10\x26\x6e\xcd\x14\x45\xf1\x2e\x67\x3c\xed\x5b\x5d\x0a\xf8\x57\x21\xe2\xc1\x7a\x18\x45\x3f\xfa\xf0\x6e\xc9\x29\xdf\x77\x7e\x8d\x3b\x45\xfb\x7e\x44\x97\xf6\x3d\x95\xc2\xc0\xb3\x29\x95\x9a\x1e\xba\x32\x81\xa4\x8f\x80\x7b\xc6\x21\x94\x83\x60\xe5\xe9\x23\x26\xe3\x4c\x9b\x44\x62\x92\x32\x6a\x9c\xfc\x9c\xec\x80\xdf\x24\x81\x12\x7a\x84\x64\x8f\x32\xf3\x4a\xd9\x27\x95\x26\xda\x29\xa8\x41\xf0\x40\xcd\x0d\xc1\x03\xb8\x2d\xdb\x23\x1e\x70\xfb\x63\xab\x65\xb5\x7e\x6d\x57\x0e\x81\x31\x25\x2a\x21\x69\xda\x99\x07\x41\x24\xe7\x78\x1d\xc5\xcc\x40\xa6\xdd\x0a\x45\x71\x2e\xd8\xb7\x1c\xfe\x59\x93\x18\xcc\xa1\x2f\x37\x45\xa9\x96\x17\x7c\x40\x99\xab\x44\x11\x2c\x02\x69\xda\xd8\x31\x95\x59\x46\xc4\x52\xd1\x35\x47\x8f\x00\xcb\x0f\x70\x3e\xb2\x43\xb6\x1e\xc3\x7e\xd5\x8e\xd6\x99\xd6\x88\x36\x7e\x7d\x86\x78\xe1\x47\x0c\x3f\x66\x14\x90\x2b\x73\xa4\xa1\x10\x30\x1d\x0a\x4e\xfa\x9c\xa5\xe1\xc4\x87\x39\xc4\x99\x4c\xbb\xf3\x16\x79\xb6\x03\x1c\x84\x64\x37\xb2\x86\xbf\xb7\x2b\xd7\x9b\xde\xea\x1b\xc2\x04\x60\x22\x48\xe6\xb3\x55\x4c\x11\x52\x10\x86\x11\x9e\x68\x05\xb4\x43\xde\xac\xd4\xc4\xca\xc4\x41\x90\x1c\x23\x1c\x98\x36\x78\x9e\x06\xa5\x17\x7b\x62\x29\x28\x10\xa9\x4e\xaa\x22\x64\x3e\x7a\xc6\x29\xb4\x15\xc9\xa2\x30\x91\x8a\xa9\x5d\xa1\x12\x53\xec\x0b\xc5\xdc\xe2\x1e\x63\xa2\x81\x20\x3d\x5e\xc9\x2f\x33\xc2\x44\xc8\xa2\x82\x30\x78\x56\x92\x55\x30\xf6\xee\xf0\x09\xc4\x29\x69\xfd\x66\xb6\x19\x40\x9c\x18\x4a\x91\x35\x20\x1d\xb6\x3b\x5b\xfc\xcf\x4a\x6a\xb8\x1d\x1c\x6b\x8e\x87\x46\xf1\x75\x1b\xd3\xdb\xae\xf5\xe2\xbd\xc4\x8c\x14\x93\x6d\xc6\xb6\x63\xb8\x33\xd4\xd0\xf3\x6c\x03\xda\x3a\x14\x59\x2d\xe1\x09\x67\xe2\x71\x79\x17\x87\x67\x83\x24\x39\x4a\x6d\xae\x49\x80\xe2\x23\x10\x6e\x8e\xf4\x08\xf4\x71\x82\xdd\xa6\xea\x70\x4b\x6d\x42\x9c\x9c\x65\xe4\xe0\x27\x52\xd4\x4b\xa2\x25\x27\xa6\x6e\x76\x4c\x11\x5e\x9d\x11\xc6\x8b\xae\x92\x25\x56\x1e\x0e\x05\xe9\x98\x6b\x0e\x2a\x8c\xfa\xb5\x2f\x37\x4f\x91\x9d\x00\x43\xd3\x4d\xa9\x2e\x85\x51\xff\x65\xc8\xb6\xef\xad\x24\x3b\xa4\x5f\xee\xaa\x42\x72\x22\xfc\xca\xff\x38\x8f\xb7\xc3\xbd\x75\xb8\xbb\xf6\x9f\xf4\x34\x0c\x4b\x88\x3b\xab\x92\x11\x5a\xe4\xbd\x08\x7a\x64\x5d\x2f\xa4\x75\x62\x9f\x0c\x92\x83\x0b\xed\x80\x78\xb0\x03\x8f\x41\xfa\x55\xf5\xc6\xfc\x3a\x2f\x68\xe9\xbc\xcd\x00\x8f\x36\x63\xd3\x0b\x9d\xe6\x65\xba\x7e\x17\x2b\xe9\x08\x67\x44\x83\x3f\xd8\x27\x0b\xb7\x56\x1a\x53\xa7\x4f\x81\x3e\xe1\xe2\xfd\xdb\x24\xef\x08\xeb\xa8\xcc\xf0\x1a\xcf\x23\xca\xce\x65\x39\x77\x4e\x64\xeb\xcf\x6e\x5f\xb3\x04\x55\xdd\x0c\xbd\x8b\x15\x25\x42\xd8\x01\xa6\x24\x9a\x9f\x52\x34\x5d\x70\xea\x92\x19\x54\x83\x0f\xeb\xa8\xfe\x72\x07\x31\xbd\x4e\xf1\x35\x81\x52\x0e\x6a\x47\xe9\xc5\x84\x81\x43\x51\xf3\xb8\x37\x81\x7c\xc7\x99\x3e\x42\x3a\x87\x07\xa5\x91\x54\xf2\xb0\xc0\x70\xb6\x89\xc2\x83\x61\xa2\x10\xbb\x2a\x89\x53\xc8\x4e\x8c\xc3\xa1\xa7\xf1\x4e\x4a\x0e\x44\x74\x36\x0a\x04\x92\x26\x52\xf0\x73\x00\xa5\x36\x04\xbd\xed\x0b\x0d\x34\x47\x66\xce\x89\x54\x66\xf1\xf4\x51\x1f\xb3\x44\xb3\xef\xd0\x8d\xbd\x8b\xd7\xd7\x82\xb6\xbd\x09\xf5\x9a\xf1\xd1\xef\x9e\xc5\xff\x4d\xcf\x42\x9f\x35\x35\xd7\xe5\xd6\xda\xa4\x4c\x24\x52\x81\xf0\xc6\x86\x36\x52\x25\x07\x24\x14\x12\x05\xc8\xa4\xd3\x14\x1d\x80\x4d\x73\xac\x4a\x83\x81\x18\xcd\x0e\x82\xb8\x71\xc7\x22\x35\x99\xda\x5f\xd9\x2d\x30\xc6\x1f\xec\x39\x67\x19\x1b\x0f\x1a\x87\xd7\x06\xe4\x6b\x55\xae\xe6\x4e\xd1\x26\xd2\xb3\x20\xc8\x9e\xa8\x10\xa6\x0b\x84\x80\xca\xe0\x48\x70\xc6\xd6\x51\x06\xe6\x7e\x64\x7f\x72\xd5\x0d\xce\x79\x75\x8e\xd5\x4b\x79\xeb\x7a\x22\x5b\x27\xfd\xac\xd4\xab\x3f\x8d\xed\x68\xf6\xe3\x0e\xaa\x5c\x7b\x8b\xb8\x92\x46\xe8\xa9\x02\xa4\x25\x1d\x9e\x0f\x47\xbf\x04\x42\x77\xd6\xa8\x24\x77\xac\x4d\x00\x8e\xd7\x23\x05\x62\xe7\x6b\xa3\x7e\x70\x46\x60\xf1\x50\x29\x34\xd3\x06\x04\x75\x37\x62\x9d\x4c\x3b\x36\x38\xe5\x18\x1a\x65\xba\xee\x0a\xab\xba\x4a\x2a\x72\x18\x6f\xc5\xb8\x6b\x93\xe0\x58\xad\xaf\x0e\xfc\x14\x55\x84\xa4\x52\x8d\x2c\x4d\xb8\x1a\x73\xb7\xd9\x5e\xeb\x62\x22\x0f\x1d\x83\x8c\x27\x89\x8f\xc5\x86\x94\x32\x37\x72\xac\x7a\x2c\x33\x2e\x1f\xf4\x9a\x82\x8d\x00\xd7\x89\xb9\x4d\xea\xbd\x85\x30\x7d\x7a\x5f\x13\x8d\x9e\xac\x33\x4d\x76\xbd\x03\x0c\xd7\x46\x5b\xec\x0c\x78\x72\xef\xf7\xfe\x84\x01\xc1\x20\xeb\x9d\x44\x34\xa9\x94\xbd\xe3\x83\x7e\x9f\xfd\x7a\xc3\x32\x90\xb9\x13\x9c\x42\xb2\x25\x82\x66\x7e\xbe\xb5\xb2\xdd\xb4\x96\x17\x5b\xf7\x1c\x3c\x2e\x64\x51\xf6\x3d\xe8\xc1\x3a\xd7\xaa\xba\x00\x5e\x37\x09\xd9\x1e\x41\xa4\xe5\x89\x4b\xd0\x5e\x8a\xa0\x38\xa3\x44\xfb\xf2\x95\x1b\x7a\xce\xb9\x4a\x89\x81\xa4\xbe\x4e\x33\x27\x43\x9c\x48\x0d\x15\x41\xc2\x39\x70\xa6\xb3\x90\x54\x2b\x4e\x81\x13\xe7\x5e\xe3\xf5\x9b\x92\x7d\x4f\x18\xcf\x11\x12\x42\x03\xfa\xf3\xf5\x4a\x09\x66\xa4\x13\xbc\xc2\x86\xcc\xc8\x73\xd2\x0c\x5b\x92\x78\xa2\xb6\x64\x92\x98\xba\x53\xad\x75\xe1\x17\x79\xe6\x48\x76\xaa\xb8\xd8\xec\x19\x6a\x53\xd5\xc4\x52\xd5\xbf\xba\xa0\xfe\x32\xda\x67\x08\x6d\x4d\x5b\x5e\x57\x65\x25\xf3\x0a\x86\x09\x77\xb8\x94\x1f\x23\xde\xd9\x8c\x38\xb0\x18\x82\x2e\x00\xb5\x3d\x39\xf0\xf2\x2f\x6a\x85\x0a\x92\x24\x67\x55\x22\xb4\x84\x29\xa8\x14\xd5\x3c\x42\xbc\xf4\xc6\xb0\x28\x7c\xb4\x28\xe3\x32\x65\xbc\x08\x52\x32\x3c\x31\x91\xca\xa7\xf9\xe8\xbb\x80\xb5\x15\x27\x14\x7a\x88\x7d\xab\xa1\xb5\x41\xc2\x84\x99\x7d\xa2\xd6\x37\x8b\x42\xd8\x03\x82\x18\x46\x44\x34\x5d\xd9\x44\xe3\xd5\x8d\x4f\x37\xbf\x86\x35\x85\x56\x45\x8a\xff\x06\x8d\xcd\x5b\x17\xff\x86\x1c\xb1\x0d\x77\xcf\xee\xde\xd2\x79\xb3\xc3\xb1\x1d\x9d\xaa\xdc\x7b\x3a\x97\x41\x26\xa7\xaf\xac\xdc\x70\x6b\xdc\xa7\x62\x43\xb6\x40\xf6\x12\x74\x9c\x5b\x53\x25\x52\x2d\xdf\x4f\xf2\x1f\xd9\x6e\xfd\xdd\x0c\xa6\x48\xb6\x14\x86\x04\x1f\x70\xc7\xce\xf4\x29\x7a\x07\xe8\x90\xef\x44\xd8\x1d\xcf\x77\x86\x0e\x76\xc6\x5c\x5f\x62\x19\x59\xd5\x87\xb6\x12\x5b\xb7\xb6\xda\x06\x2f\xf1\xe8\x0d\x92\xe5\xe6\x5f\x16\x85\xfd\x26\xb0\xab\x7a\x24\xc6\x10\x7a\x0c\x2a\x34\x67\xe6\xfb\x37\xe0\xd0\xa0\x1d\xe2\x84\xa1\x9a\x6a\x01\x14\x0a\xb9\xd2\xf3\xbf\x81\x54\xbf\xba\x5f\xff\x3c\x1f\xac\x3f\x6e\xf1\x7e\x40\x51\x52\x5d\xbd\xd7\x07\x5c\x51\x7d\x07\x6b\xf6\xc6\x4b\x31\xd8\xe8\x9c\x4b\x51\x53\xfd\x5e\x8a\x57\x8d\x8a\xee\xa1\xa0\xb5\x24\xc3\x6e\xe0\x94\x25\x83\x6f\x2e\xd5\x1c\xdb\xee\x34\xfa\x64\x8e\x4f\x41\xbb\xb9\xcf\xd4\x95\x81\x86\x64\xa4\x27\xdd\x1b\xb4\x36\xe2\xb4\xe6\x0b\xe2\xfe\xdd\x87\x89\x0c\x6f\xea\x86\xe1\x2b\xa5\x46\x0b\x5c\xc7\x70\xaf\x69\xaf\x78\x6e\xac\x3b\xfc\x92\x6d\x3c\xfe\x1b\xfe\xc1\x77\x6d\x85\x9e\xe2\x3c\xe8\x56\xff\xe8\x1e\xc0\x55\xdf\xa4\x6d\x3b\xf6\xe9\x91\x54\x17\x7b\xad\x8d\x76\x6b\xf7\x13\x46\xbf\x44\x70\x7d\xed\xd6\x3f\xfe\x6b\xbe\x3a\x1b\xb9\x91\xb0\xb2\xff\x96\x5f\x11\xae\x5e\x56\xff\x0d\x00\x00\xff\xff\xaa\xc2\x0c\x76\xaf\x3d\x00\x00") +var _dataConfig_schema_v35Json = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x1b\xc9\x72\xec\xb6\xf1\x3e\x5f\xc1\x82\x7d\xb3\x16\x57\xc5\x49\x55\xde\x2d\xc7\x9c\x92\x73\x54\xf3\x58\x18\xb0\x87\x03\x0b\x04\x60\x00\x1c\x69\xfc\x4a\xff\x9e\xe2\x2a\x90\xc4\x46\x0d\xf5\x24\x27\x3e\x49\x43\x76\x37\xd0\xfb\x02\xf0\xdb\x2e\xcb\xd0\x8f\x9a\x9c\xa0\xc2\xe8\x4b\x86\x4e\xc6\xc8\x2f\xf7\xf7\xbf\x6a\xc1\x6f\xbb\xa7\x77\x42\x95\xf7\x85\xc2\x47\x73\xfb\xf3\x2f\xf7\xdd\xb3\x1f\xd0\x4d\x83\x47\x8b\x06\x85\x08\x7e\xa4\x65\xde\xbd\xc9\xcf\x7f\xb9\xfb\xeb\x5d\x83\xde\x81\x98\x8b\x84\x06\x48\x1c\x7e\x05\x62\xba\x67\x0a\x7e\xab\xa9\x82\x06\xf9\x01\x9d\x41\x69\x2a\x38\xda\xdf\xec\x9a\x77\x52\x09\x09\xca\x50\xd0\xe8\x4b\xd6\x6c\x2e\xcb\x46\x90\xe1\x81\x45\x56\x1b\x45\x79\x89\xda\xc7\x2f\x2d\x85\x2c\x43\x1a\xd4\x99\x12\x8b\xc2\xb8\xd5\x1f\xee\x5f\xe9\xdf\x8f\x60\x37\x73\xaa\xd6\x66\xdb\xe7\x12\x1b\x03\x8a\xff\x7b\xb9\xb7\xf6\xf5\xd7\x07\x7c\xfb\xfb\x3f\x6e\xff\xf3\xf3\xed\xdf\xef\xf2\xdb\xfd\x4f\x3f\x4e\x5e\x37\xf2\x55\x70\xec\x96\x2f\xe0\x48\x39\x35\x54\xf0\x71\x7d\x34\x42\xbe\xf4\xff\xbd\x8c\x0b\xe3\xa2\x68\x81\x31\x9b\xac\x7d\xc4\x4c\xc3\x94\x67\x0e\xe6\x49\xa8\xc7\x18\xcf\x23\xd8\x07\xf1\xdc\xaf\xef\xe0\x79\xca\xce\x59\xb0\xba\x8a\x6a\x70\x80\xfa\x20\x66\xba\xe5\xb7\xd1\x9f\x06\xa2\xc0\xc4\x4d\xb6\x83\xfa\x30\x8b\x6d\x96\xdf\x86\xe1\x2e\x6a\xc4\x18\x1e\xa0\x3e\x88\xe1\x6e\xf9\xeb\x18\xde\x0d\x4c\xbb\xf7\x88\xbe\x3e\xdf\x36\x7f\x5f\x5a\x9a\x41\x7a\x1d\x15\x6b\x7f\x2d\x13\x93\x98\xe7\x12\xa7\x2b\xe6\xf8\xe5\x39\x0a\xd4\x23\xc9\x02\x24\x13\x97\x76\xe7\x6e\x99\x75\x00\x15\x70\x83\x46\x31\x65\x19\x3a\xd4\x94\x15\x73\xa9\x0b\x0e\xff\x6a\x48\x3c\x58\x0f\xb3\xec\xdb\x3c\xbc\x5b\x74\xda\xf7\x93\x5f\x7e\xa3\x18\xdf\x7b\x78\x19\xdf\x13\xc1\x0d\x3c\x9b\x96\xa9\xf0\xd2\x9d\x08\x04\x79\x04\x75\xa4\x0c\x52\x31\xb0\xea\x2c\xdd\x23\x32\x46\xb5\xc9\x85\xca\x0b\x4a\x8c\x13\x9f\xe1\x03\xb0\xab\x28\x10\x4c\x4e\x90\x1f\x95\xa8\xa2\x54\x8e\x79\xc7\x89\x76\x12\x1a\x22\x78\x22\xe7\x06\xab\x12\xdc\x92\x9d\x01\x2f\xb0\xe3\xbe\x35\xa2\x5a\xbf\xf6\x3b\x07\x41\x44\xb0\xcc\x71\x51\x4c\xf6\x81\x95\xc2\x17\x74\x93\x21\x6a\xa0\xd2\x6e\x86\x32\x54\x73\xfa\x5b\x0d\xff\xec\x41\x8c\xaa\x61\x4e\xb7\x50\x42\x6e\x4f\xb8\x54\xa2\x96\xb9\xc4\xaa\x71\xa4\xb0\xb0\x11\x11\x55\x85\xf9\x56\xde\xb5\x86\x8f\x04\xc9\x2f\xe2\x7c\x66\xbb\x6c\xbf\x86\xfd\x6a\x5c\x6d\xb2\x2d\x0f\x37\x71\x7e\x96\xf1\x22\x1e\x31\xe2\x31\xa3\x09\xb9\xa2\x56\x24\x35\x04\x84\x5d\xc1\x09\x5f\xd3\x22\x1d\xb8\x5c\x03\x5c\x89\x62\xba\x6f\x5e\x57\x07\x50\x0b\x97\x9c\x7a\xd6\xf2\xf7\x7e\xe7\x7a\x33\xd3\xbe\xc1\x94\x83\xca\x39\xae\x62\xb2\x42\x44\x41\x01\xdc\x50\xcc\x72\x2d\x81\x4c\xc0\x07\x4d\x05\x34\x83\x92\x42\x32\x52\x50\x52\x6d\xd4\x25\x1c\x94\x5e\xec\x8d\x15\x20\x81\x17\x3a\xef\x9a\x90\xf5\xd1\x13\x15\x30\x76\x24\x9b\x86\x89\x82\x87\xb2\x42\x47\xa6\xc9\x0b\xcd\xde\xd0\x0c\x31\xd7\x80\x15\x39\xbd\x11\x5f\x54\x98\xf2\x14\xa5\x02\x37\xea\x22\x05\xed\xc2\xd8\xa7\x8b\x4f\xc0\xcf\xf9\x68\x37\xab\xc5\x00\xfc\x4c\x95\xe0\xd5\x10\xa4\xd3\xb2\xb3\x85\xff\x2c\x85\x86\xeb\x83\x63\x8f\xf1\x30\x30\x7e\x33\xfa\xf4\x7e\x2a\x3d\x74\x14\xaa\xc2\xcd\x66\x87\xb5\x6d\x1f\x9e\x2c\xb5\xb4\x3c\x5b\x80\x36\x0f\x4d\x55\x8b\x59\xce\x28\x7f\xdc\xde\xc4\xe1\xd9\x28\x9c\x9f\x84\x36\x6f\x29\x80\xd0\x09\x30\x33\x27\x72\x02\xf2\x18\x40\xb7\xa1\x26\xd8\x42\x9b\x14\x23\xa7\x15\x2e\xe3\x40\x92\x44\x41\xb4\x60\xd8\xf4\xc3\x8e\x10\xe0\x9b\x2b\x42\xb4\xa9\x96\x2c\xb2\xa2\x2c\x1b\x50\x9f\x69\x2e\x3a\x8c\xfe\x75\xac\x36\x2f\x14\x3d\x83\x4a\x2d\x37\x85\x7c\x6d\x8c\xe6\x2f\x53\xd2\x7e\xb4\x93\x9c\x80\x7e\xbd\xeb\x1a\xc9\x80\xfb\xb5\xff\x31\x86\xf6\xcb\xdc\xba\xcc\xae\xf3\x27\x33\x0e\xd3\x0a\xe2\x89\x56\x2a\x4c\x9a\xba\x57\x81\xf6\xe8\xf5\x15\xb4\x2f\xec\xf3\x45\x71\xf0\x0a\xbb\x00\x5e\x64\x60\x5f\x48\x7f\x53\xbf\xb1\xbe\xcf\x4b\x52\x5d\x74\x18\x10\xe1\xc6\xb7\xbd\xd4\x6d\xbe\x6e\x37\x6e\x62\x2d\x1c\x66\x14\x6b\x88\x3b\x7b\xb0\x71\x1b\xa9\x51\x79\xfe\x25\xd1\x26\x5c\xb8\x7f\x0b\xe2\x7a\x50\xbd\x34\xd3\x7b\xbc\x08\x29\xbb\x96\x65\xcc\xb9\x91\x7d\xbc\xba\x7d\xcf\x16\x54\x4e\x2b\xf4\x69\xac\x68\x23\x84\xed\x60\x52\x28\xf3\x5d\x9a\xa6\xd7\x38\xf5\x5a\x19\x74\x8b\x2f\xfb\xa8\xb9\xba\x93\x90\xde\xa7\xf9\x0a\x44\x29\x07\xb4\xa3\xf5\xa2\xdc\x40\xd9\xf4\x3c\xee\x24\x50\x1f\x18\xd5\x27\x28\xd6\xe0\x28\x61\x04\x11\x2c\xcd\x31\x9c\x63\xa2\x74\x67\x08\x34\x62\x6f\x2a\xe2\xa4\xa2\x67\xca\xa0\x9c\x71\x7c\x10\x82\x01\xe6\x93\x44\xa1\x00\x17\xb9\xe0\xec\x92\x00\xa9\x0d\x56\xd1\xf1\x85\x06\x52\x2b\x6a\x2e\xb9\x90\x66\xf3\xf2\x51\x9f\xaa\x5c\xd3\xdf\x61\xea\x7b\xaf\x56\xdf\x13\xda\xcf\x36\x34\x1b\xc6\x67\x7f\xce\x2c\xfe\x6f\x66\x16\xfa\xa2\x89\x79\x5b\x6d\xad\x4d\x41\x79\x2e\x24\xf0\xa8\x6f\x68\x23\x64\x5e\x2a\x4c\x20\x97\xa0\xa8\x70\x8a\x62\x12\x60\x8b\x5a\x75\xad\xc1\x82\x8c\xa6\x25\xc7\xee\xb8\x63\x81\x9a\x4a\x1e\xdf\x38\x2d\x30\x26\xee\xec\x35\xa3\x15\xf5\x3b\x8d\xc3\x6a\x13\xea\xb5\xae\x56\x73\x97\x68\x81\xf2\x2c\x29\x64\x07\x3a\x84\x70\x83\x90\xd0\x19\x9c\xb0\x5a\x91\x3a\x5a\xc7\x3c\x7a\xf2\x93\xab\x6f\x70\xee\x6b\x72\xac\xde\xd2\xbb\xe9\x37\xb2\x77\xc2\xaf\x2a\xbd\xe6\xdb\xd8\x7b\xab\x1f\xb7\x53\xd5\x3a\xda\xc4\xb5\x30\x5c\x87\x1a\x90\x11\x74\x79\x3e\x9c\xfd\x21\x22\xf4\x44\x47\x2d\xb8\x43\x37\x09\x71\xbc\x5f\x29\x31\x76\xbe\x77\xd4\x4f\xae\x08\x2c\x1c\x22\xb8\xa6\xda\x00\x27\xee\x41\xac\x13\xe9\x40\x17\xa7\x1c\x4b\xa1\x84\xfb\xae\xb4\xae\xab\x85\xc2\xa5\x7f\x14\xe3\xee\x4d\x92\x7d\xb5\xbf\x3a\xf0\x5d\x58\xe1\x82\x08\xe9\x51\x4d\x3a\x1b\x6b\xd3\xec\x6c\x74\x11\xa8\x43\x7d\x21\xe3\x49\xa8\xc7\x26\x21\x15\xd4\x1d\x39\x76\x33\x94\x15\x97\x0f\x66\x43\xc1\x81\x80\xeb\xc4\xdc\x06\x8d\xde\x42\x08\x9f\xde\xf7\x40\xde\x93\x75\xaa\xf1\x61\x76\x80\xe1\x4a\xb4\x4d\x66\x50\x67\x77\xbe\x8f\x17\x0c\x0a\x8c\xa2\xb3\x93\x88\xa1\x94\xb2\x33\x3e\xe8\xcf\x39\xaf\x37\xb4\x02\x51\x3b\x83\x53\x4a\xb5\x84\x95\x59\x5f\x6f\xed\x6c\x33\xed\xe9\x21\xeb\x9e\x43\xc4\x84\x2c\xc8\xb9\x05\x3d\x58\xe7\x5a\xdd\x14\x20\x6a\x26\x29\xe9\x11\x78\xd1\x9e\xb8\x24\xe5\x52\x05\x92\x51\x82\x75\xac\x5e\xb9\x62\xe6\x5c\xcb\x02\x1b\xc8\xfb\xeb\x34\x6b\x2a\xc4\x40\x69\x28\xb1\xc2\x8c\x01\xa3\xba\x4a\x29\xb5\x50\x01\x0c\x3b\x73\x4d\xd4\x6e\x5a\xf4\x23\xa6\xac\x56\x90\x63\x92\x30\x9f\xef\x35\xc5\xa9\x11\xce\xe0\x95\xb6\x64\x85\x9f\xf3\x61\xd9\x16\x24\xe2\xb5\x2d\x92\x50\x85\xbb\xd4\xba\x69\xec\xa2\xae\x1c\xc5\x4e\xe7\x17\xb7\x47\xaa\xb4\xe9\x7a\x62\x21\xfb\x5f\xd3\xa0\xfe\xe2\x9d\x33\xa4\x8e\xa6\x2d\xab\xeb\xaa\x92\x75\x0d\x43\xc0\x1c\x9c\xed\x47\x8c\x62\x8c\x6a\xfb\x9e\xc8\x3a\x75\x52\x8a\x2a\xa8\x44\xec\x68\xd9\x21\xbf\x74\x19\x3a\x50\x1b\x59\x36\x19\xc1\x77\xf4\xf1\x59\x04\xe0\x80\x2e\x81\x83\xa2\x24\x9f\x58\x83\x27\xba\x2c\x61\xdf\x69\x7e\x7b\xbd\x65\x77\x69\x46\x30\xda\x15\xb7\x5b\x98\x37\x11\xbc\xdb\x47\x4a\xe4\xb9\x32\xd4\x35\x71\xa7\x69\xcd\x2b\x69\xa2\x59\xa1\x45\x78\xa2\xbc\x10\x4f\xeb\x33\xea\x06\xd2\x96\x0c\x13\x98\x65\xe1\x6b\x05\xad\x8d\xc2\x94\x9b\xd5\xa7\xa4\x73\xb1\x48\x05\x47\x50\xc0\x97\x51\x2e\x0b\x77\xab\x99\xbf\x63\x8d\xf1\x16\xe7\xb0\x87\xd0\xb2\x69\xdb\x3e\x60\x58\x7d\xad\xf2\xaf\xa8\xfb\x9d\xe1\x26\x54\xba\x2d\x11\x16\x3d\xc0\x54\x7b\x0e\xad\xf9\xb5\x15\xb8\xca\x54\x50\x4d\x14\x18\x18\x57\x1e\x6f\x44\x4d\x4d\x2c\x68\x09\x61\x2b\x40\x8f\x7d\x37\x1d\x0d\xd4\xe8\x8c\x59\x9d\x30\x7d\x7d\xd3\x79\xb5\xaf\xfd\x4b\x40\x9e\x7d\x34\x60\x5d\x4d\x0d\xe9\x74\x00\xdb\xa0\x16\x4f\xba\x9c\xd0\x43\xe5\x42\x6e\x3f\x1d\x8d\x5f\x40\xd8\xc7\x67\x73\x54\xe2\x6a\xab\xe8\x99\x7c\x5d\x03\x39\x9b\x81\xec\x13\xc4\xc5\xfa\xc0\xd3\x6e\x2c\x7f\xb2\xb8\x68\xf7\x7f\xfd\x95\x2c\x8f\x56\x1f\xc6\xb9\xc2\xcd\x28\xab\x7d\xb2\x8a\xbd\xf7\xa1\xb6\xdb\x7f\x3b\xe2\x98\x1f\x69\xb8\x66\x21\xd8\x18\x4c\x4e\x49\x63\x93\x95\xdd\xeb\x15\x59\x66\x31\xdc\x73\x86\xa1\x1e\x6a\x83\x28\x94\x72\x41\xed\x7f\x23\x52\xfd\xd1\xed\xfa\xfb\xd9\x60\xff\xa9\x56\xf4\x73\xa0\x16\x2a\x3a\xd7\xf4\x59\x5e\xc2\x85\xeb\x4f\xa0\xb3\x0f\x56\xc5\x22\xd1\x39\x55\xd1\x43\xfd\xa9\x8a\x77\xf5\x8a\xe9\x11\xb7\xa5\x92\xe5\x6c\x3b\x24\xc9\xe4\x7b\x78\x3d\xc6\x7e\xba\x8d\x39\x98\xe3\xc3\x66\x5f\x57\xe1\xdd\x94\xef\x84\x65\xb6\x68\x2f\xc4\x30\xe7\x1b\xc6\xfd\xbb\x9f\x02\x15\x5e\xe8\xbe\xec\x3b\x95\x46\x1b\x5c\x2e\x72\xeb\x74\x36\x36\x18\xa4\xbb\xfc\x2e\xd3\xef\xff\x03\xfe\xe2\x2b\xcd\x86\x4f\x7e\x59\x9c\xbd\x7c\x9b\x1e\x27\x77\x5f\x58\xee\x27\xf2\x99\x81\x74\xd7\xd4\xad\x44\xbb\x4f\x6a\x46\x5d\xdf\x6e\xce\x0f\xb3\x87\x6f\x28\x3d\xf7\x6b\x76\xf6\xdf\xf6\x9b\xd8\xdd\xcb\xee\xbf\x01\x00\x00\xff\xff\xd7\xf3\x50\x9f\x7d\x40\x00\x00") func dataConfig_schema_v35JsonBytes() ([]byte, error) { return bindataRead( diff --git a/cli/compose/schema/data/config_schema_v3.5.json b/cli/compose/schema/data/config_schema_v3.5.json index 1151bb06424f..45885b23e8e1 100644 --- a/cli/compose/schema/data/config_schema_v3.5.json +++ b/cli/compose/schema/data/config_schema_v3.5.json @@ -354,8 +354,23 @@ "resources": { "type": "object", "properties": { - "limits": {"$ref": "#/definitions/resource"}, - "reservations": {"$ref": "#/definitions/resource"} + "limits": { + "type": "object", + "properties": { + "cpus": {"type": "string"}, + "memory": {"type": "string"} + }, + "additionalProperties": false + }, + "reservations": { + "type": "object", + "properties": { + "cpus": {"type": "string"}, + "memory": {"type": "string"}, + "generic_resources": {"$ref": "#/definitions/generic_resources"} + }, + "additionalProperties": false + } }, "additionalProperties": false }, @@ -390,14 +405,23 @@ "additionalProperties": false }, - "resource": { - "id": "#/definitions/resource", - "type": "object", - "properties": { - "cpus": {"type": "string"}, - "memory": {"type": "string"} - }, - "additionalProperties": false + "generic_resources": { + "id": "#/definitions/generic_resources", + "type": "array", + "items": { + "type": "object", + "properties": { + "discrete_resource_spec": { + "type": "object", + "properties": { + "kind": {"type": "string"}, + "value": {"type": "number"} + }, + "additionalProperties": false + } + }, + "additionalProperties": false + } }, "network": { diff --git a/cli/compose/types/types.go b/cli/compose/types/types.go index 296e2595756d..b31231c7e237 100644 --- a/cli/compose/types/types.go +++ b/cli/compose/types/types.go @@ -217,8 +217,24 @@ type Resources struct { // Resource is a resource to be limited or reserved type Resource struct { // TODO: types to convert from units and ratios - NanoCPUs string `mapstructure:"cpus"` - MemoryBytes UnitBytes `mapstructure:"memory"` + NanoCPUs string `mapstructure:"cpus"` + MemoryBytes UnitBytes `mapstructure:"memory"` + GenericResources []GenericResource `mapstructure:"generic_resources"` +} + +// GenericResource represents a "user defined" resource which can +// only be an integer (e.g: SSD=3) for a service +type GenericResource struct { + DiscreteResourceSpec *DiscreteGenericResource `mapstructure:"discrete_resource_spec"` +} + +// DiscreteGenericResource represents a "user defined" resource which is defined +// as an integer +// "Kind" is used to describe the Kind of a resource (e.g: "GPU", "FPGA", "SSD", ...) +// Value is used to count the resource (SSD=5, HDD=3, ...) +type DiscreteGenericResource struct { + Kind string + Value int64 } // UnitBytes is the bytes type