Add maximum replicas per node support to stack version 3.8

Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
This commit is contained in:
Olli Janatuinen 2018-09-30 17:04:35 +03:00
parent 1b8d1e23c5
commit 6347ab315b
6 changed files with 48 additions and 40 deletions

View File

@ -158,6 +158,7 @@ func Service(
Placement: &swarm.Placement{ Placement: &swarm.Placement{
Constraints: service.Deploy.Placement.Constraints, Constraints: service.Deploy.Placement.Constraints,
Preferences: getPlacementPreference(service.Deploy.Placement.Preferences), Preferences: getPlacementPreference(service.Deploy.Placement.Preferences),
MaxReplicas: service.Deploy.Placement.MaxReplicas,
}, },
}, },
EndpointSpec: endpoint, EndpointSpec: endpoint,

View File

@ -1,4 +1,4 @@
version: "3.7" version: "3.8"
services: services:
foo: foo:
@ -82,6 +82,7 @@ services:
window: 120s window: 120s
placement: placement:
constraints: [node=foo] constraints: [node=foo]
max_replicas_per_node: 5
preferences: preferences:
- spread: node.labels.az - spread: node.labels.az
endpoint_mode: dnsrr endpoint_mode: dnsrr

View File

@ -10,7 +10,7 @@ import (
func fullExampleConfig(workingDir, homeDir string) *types.Config { func fullExampleConfig(workingDir, homeDir string) *types.Config {
return &types.Config{ return &types.Config{
Version: "3.7", Version: "3.8",
Services: services(workingDir, homeDir), Services: services(workingDir, homeDir),
Networks: networks(), Networks: networks(),
Volumes: volumes(), Volumes: volumes(),
@ -111,6 +111,7 @@ func services(workingDir, homeDir string) []types.ServiceConfig {
}, },
Placement: types.Placement{ Placement: types.Placement{
Constraints: []string{"node=foo"}, Constraints: []string{"node=foo"},
MaxReplicas: uint64(5),
Preferences: []types.PlacementPreferences{ Preferences: []types.PlacementPreferences{
{ {
Spread: "node.labels.az", Spread: "node.labels.az",
@ -507,7 +508,7 @@ func secrets(workingDir string) map[string]types.SecretConfig {
} }
func fullExampleYAML(workingDir string) string { func fullExampleYAML(workingDir string) string {
return fmt.Sprintf(`version: "3.7" return fmt.Sprintf(`version: "3.8"
services: services:
foo: foo:
build: build:
@ -588,6 +589,7 @@ services:
- node=foo - node=foo
preferences: preferences:
- spread: node.labels.az - spread: node.labels.az
max_replicas_per_node: 5
endpoint_mode: dnsrr endpoint_mode: dnsrr
devices: devices:
- /dev/ttyUSB0:/dev/ttyUSB0 - /dev/ttyUSB0:/dev/ttyUSB0
@ -1083,7 +1085,8 @@ func fullExampleJSON(workingDir string) string {
{ {
"spread": "node.labels.az" "spread": "node.labels.az"
} }
] ],
"max_replicas_per_node": 5
}, },
"endpoint_mode": "dnsrr" "endpoint_mode": "dnsrr"
}, },
@ -1383,7 +1386,7 @@ func fullExampleJSON(workingDir string) string {
"working_dir": "/code" "working_dir": "/code"
} }
}, },
"version": "3.7", "version": "3.8",
"volumes": { "volumes": {
"another-volume": { "another-volume": {
"name": "user_specified_name", "name": "user_specified_name",

View File

@ -510,44 +510,45 @@ nEbFye/DBpf6q/LNQD4WSf11TQ8obKICc9f36nZ7TfvduKfjbxi9rsq/59X/AwAA//+9o87pcUUAAA==
"/data/config_schema_v3.8.json": { "/data/config_schema_v3.8.json": {
local: "data/config_schema_v3.8.json", local: "data/config_schema_v3.8.json",
size: 17777, size: 17835,
modtime: 1518458244, modtime: 1518458244,
compressed: ` compressed: `
H4sIAAAAAAAC/+xcS4/bOBK++1cYmrlNPwLsYLGb2x73tHvehiPQVNnmNEVyipTTTuD/vtDTEkWKlK1O H4sIAAAAAAAC/+xcS4/bOBK++1cYmrlNPwLsYLGb2x73tHvehiPQVNnmNEVyipTTTuD/vtCzJYoUKVtO
dzAdIEi3VHzUg8WvHsr31Xqd/KrpAXKSfF4nB2PU58fHP7QU9/XTB4n7xwzJztx/+v2xfvZLcleOY1k5 dzAdIEi3VHzUg8WvHsr31Xqd/KrpAXKSfF4nB2PU58fHP7QU9/XTB4n7xwzJztx/+v2xfvZLcleOY1k5
hEqxY/u0fpMe//bwj4dyeE1iTgpKIrn9A6ipnyH8WTCEcvBTcgTUTIpkc7cq3ymUCtAw0Mnndbm59boj hEqxY/u0fpMe//bwj4dyeE1iT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Px4wCgyH2nNoza+tia7DjGmKYKBbuWteXMVbwrQVJM9NTivoqJMj Rssl5BUCyd6gZOSythaYloA9FTaSdWUkLzGbKz5LcDqqqUhgPGAUUg717tC3X88T/YoZ0xTBQLdy1/a4
4UVEDeSqrhFf7iBi8Nn5rVNIpy3ZAgFaTBdXVBtRQ5VKtXwdI9wqtAln0Zki+VIeNrqxKnEGDO/BdxZb irehaftJnptsWNDFJ0fCi4jqyUX9Jr6sQ8Tgs/MrqZBOW7IFQruY/q+oBqSGKpVq+QpIuMloE86/M0Xy
4UlTv2/feTfusPRo9alLSN11stpEq9h7MJbbf5Ubs4uPriQaMYbQQ1S+bWba4wekL0fpeqdLa6g+PNoM pXxzdEtW4gw13oPXLbbCk+C+sddd7sptezM9Wn3qUll3naw20Sr2Hozl9l9l1eyypSv9Rowh9BCVqZuZ
j/az2//7s9XmM9Dgp4YVVfjLzRssNOKbjXeg/59EraNL2KnWhupDrT+LWq2mm556x8WfKYlHdwav+rWe MPkBic9Rot/p0hqqD482w6P97Pb//my1+YA0+JFiRRX+5vMKC4342uMd6P8nUevoEnaqtaH6UOvPolar
bhs2meM/c/BFWN5N+UqV1qKNsKc5X/DeevhtAslOdfC/EgRcoN3RrVMrhbLqmhvtb9H9vqQdP/oyveRT Xaen3nHZaEri0T3Fq36VqNuGTeb4byB8EZZ3U74ip7VoI+xpzhe8tx5+m0CyU73/N4KACzRKunVqJV9W
nEbFye/DBpf6q/LNQD4WSf11TQ8obKICc9f36nZ7TfvduKfjbxi9rsq/59X/AwAA///OY0uPcUUAAA== XVuk/RW735e040fftJd8itOorPl92BpTf4++GcjHIqm/y+kBhU1UYO760t1uzGm/OPf0Cg6j11X597z6
fwAAAP//uQ4+qatFAAA=
`, `,
}, },

View File

@ -424,7 +424,8 @@
}, },
"additionalProperties": false "additionalProperties": false
} }
} },
"max_replicas_per_node": {"type": "integer"}
}, },
"additionalProperties": false "additionalProperties": false
} }

View File

@ -346,6 +346,7 @@ type RestartPolicy struct {
type Placement struct { type Placement struct {
Constraints []string `yaml:",omitempty" json:"constraints,omitempty"` Constraints []string `yaml:",omitempty" json:"constraints,omitempty"`
Preferences []PlacementPreferences `yaml:",omitempty" json:"preferences,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 // PlacementPreferences is the preferences for a service placement