diff --git a/cli/compose/convert/service.go b/cli/compose/convert/service.go index d2bfcbaa55..7c98244d8e 100644 --- a/cli/compose/convert/service.go +++ b/cli/compose/convert/service.go @@ -158,6 +158,7 @@ func Service( Placement: &swarm.Placement{ Constraints: service.Deploy.Placement.Constraints, Preferences: getPlacementPreference(service.Deploy.Placement.Preferences), + MaxReplicas: service.Deploy.Placement.MaxReplicas, }, }, EndpointSpec: endpoint, diff --git a/cli/compose/loader/full-example.yml b/cli/compose/loader/full-example.yml index 2dd5799a19..518c5d8c3d 100644 --- a/cli/compose/loader/full-example.yml +++ b/cli/compose/loader/full-example.yml @@ -1,4 +1,4 @@ -version: "3.7" +version: "3.8" services: foo: @@ -82,6 +82,7 @@ services: window: 120s placement: constraints: [node=foo] + max_replicas_per_node: 5 preferences: - spread: node.labels.az endpoint_mode: dnsrr diff --git a/cli/compose/loader/full-struct_test.go b/cli/compose/loader/full-struct_test.go index 758557fcf4..355c389447 100644 --- a/cli/compose/loader/full-struct_test.go +++ b/cli/compose/loader/full-struct_test.go @@ -10,7 +10,7 @@ import ( func fullExampleConfig(workingDir, homeDir string) *types.Config { return &types.Config{ - Version: "3.7", + Version: "3.8", Services: services(workingDir, homeDir), Networks: networks(), Volumes: volumes(), @@ -111,6 +111,7 @@ func services(workingDir, homeDir string) []types.ServiceConfig { }, Placement: types.Placement{ Constraints: []string{"node=foo"}, + MaxReplicas: uint64(5), Preferences: []types.PlacementPreferences{ { Spread: "node.labels.az", @@ -507,7 +508,7 @@ func secrets(workingDir string) map[string]types.SecretConfig { } func fullExampleYAML(workingDir string) string { - return fmt.Sprintf(`version: "3.7" + return fmt.Sprintf(`version: "3.8" services: foo: build: @@ -588,6 +589,7 @@ services: - node=foo preferences: - spread: node.labels.az + max_replicas_per_node: 5 endpoint_mode: dnsrr devices: - /dev/ttyUSB0:/dev/ttyUSB0 @@ -1083,7 +1085,8 @@ func fullExampleJSON(workingDir string) string { { "spread": "node.labels.az" } - ] + ], + "max_replicas_per_node": 5 }, "endpoint_mode": "dnsrr" }, @@ -1383,7 +1386,7 @@ func fullExampleJSON(workingDir string) string { "working_dir": "/code" } }, - "version": "3.7", + "version": "3.8", "volumes": { "another-volume": { "name": "user_specified_name", diff --git a/cli/compose/schema/bindata.go b/cli/compose/schema/bindata.go index 5fea6ddb77..5a8d6ffd73 100644 --- a/cli/compose/schema/bindata.go +++ b/cli/compose/schema/bindata.go @@ -510,44 +510,45 @@ nEbFye/DBpf6q/LNQD4WSf11TQ8obKICc9f36nZ7TfvduKfjbxi9rsq/59X/AwAA//+9o87pcUUAAA== "/data/config_schema_v3.8.json": { local: "data/config_schema_v3.8.json", - size: 17777, + size: 17835, modtime: 1518458244, compressed: ` -H4sIAAAAAAAC/+xcS4/bOBK++1cYmrlNPwLsYLGb2x73tHvehiPQVNnmNEVyipTTTuD/vtDTEkWKlK1O +H4sIAAAAAAAC/+xcS4/bOBK++1cYmrlNPwLsYLGb2x73tHvehiPQVNnmNEVyipTTTuD/vtCzJYoUKVtO dzAdIEi3VHzUg8WvHsr31Xqd/KrpAXKSfF4nB2PU58fHP7QU9/XTB4n7xwzJztx/+v2xfvZLcleOY1k5 hEqxY/u0fpMe//bwj4dyeE1iTgpKIrn9A6ipnyH8WTCEcvBTcgTUTIpkc7cq3ymUCtAw0Mnndbm59boj -aR/0ptUGmdgn1eNzNcN6nWjAI6O9Gbqt/vJ4mf+xI7uzZ+1ttnquiDGA4r/jvVWvvzyR+2//uv/fp/t/ -PqT3m99+Hbwu5Yuwq5fPYMcEM0yKbv2kozw3P527hUmWVcSED9beEa5hyLMA81Xic4jnjuyNeG7Wd/A8 -ZOcoeZEHNdhSvREz9fLL6E8DRTBhk62p3sxiy+WXYbj2GiGGW6o3Yrhe/jaGVy3T7j0mX17uy3/P1ZyT -89Wz9PZXMTHweS5xunyOX56dQD2SzEBxeap27pZZTZCDMEknpvU62RaMZ7bUpYD/lFM89R6u199t996b -p3o/+M1vFN17Dy/deyqFgRdTMTW9dC0CSZ8Bd4xD7Ai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KtX5lIpNf58OsBaStOKFgQbNrBa0NEibM7F4FWywKYQcIgsLksRznjCby +Rssl5BUCyd6gZOSythaYloA9FTaSdWUkLzGbKz5LcDqqqUhgPGAUUg717tC3X88T/YoZ0xTBQLdy1/a4 +irehaftJnptsWNDFJ0fCi4jqyUX9Jr6sQ8Tgs/MrqZBOW7IFQruY/q+oBqSGKpVq+QpIuMloE86/M0Xy +pXxzdEtW4gw13oPXLbbCk+C+sddd7sptezM9Wn3qUll3naw20Sr2Hozl9l9l1eyypSv9Rowh9BCVqZuZ +MPkBic9Rot/p0hqqD482w6P97Pb//my1+YA0+JFiRRX+5vMKC4342uMd6P8nUevoEnaqtaH6UOvPolar +Xaen3nHZaEri0T3Fq36VqNuGTeb4byB8EZZ3U74ip7VoI+xpzhe8tx5+m0CyU73/N4KACzRKunVqJV9W +XVuk/RW735e040fftJd8itOorPl92BpTf4++GcjHIqm/y+kBhU1UYO760t1uzGm/OPf0Cg6j11X597z6 +fwAAAP//uQ4+qatFAAA= `, }, diff --git a/cli/compose/schema/data/config_schema_v3.8.json b/cli/compose/schema/data/config_schema_v3.8.json index 81f89d65c4..a12a40ef8f 100644 --- a/cli/compose/schema/data/config_schema_v3.8.json +++ b/cli/compose/schema/data/config_schema_v3.8.json @@ -424,7 +424,8 @@ }, "additionalProperties": false } - } + }, + "max_replicas_per_node": {"type": "integer"} }, "additionalProperties": false } diff --git a/cli/compose/types/types.go b/cli/compose/types/types.go index e427cdba42..4372899495 100644 --- a/cli/compose/types/types.go +++ b/cli/compose/types/types.go @@ -346,6 +346,7 @@ type RestartPolicy struct { type Placement struct { Constraints []string `yaml:",omitempty" json:"constraints,omitempty"` Preferences []PlacementPreferences `yaml:",omitempty" json:"preferences,omitempty"` + MaxReplicas uint64 `mapstructure:"max_replicas_per_node" yaml:"max_replicas_per_node,omitempty" json:"max_replicas_per_node,omitempty"` } // PlacementPreferences is the preferences for a service placement