Merge pull request #360 from akalipetis/compose-update-order

Add support for update order in compose deployments
This commit is contained in:
Sebastiaan van Stijn 2017-08-01 22:24:48 +02:00 committed by GitHub
commit 1cd402b192
7 changed files with 27 additions and 2 deletions

View File

@ -455,6 +455,7 @@ func convertUpdateConfig(source *composetypes.UpdateConfig) *swarm.UpdateConfig
FailureAction: source.FailureAction,
Monitor: source.Monitor,
MaxFailureRatio: source.MaxFailureRatio,
Order: source.Order,
}
}

View File

@ -343,3 +343,21 @@ func TestConvertCredentialSpec(t *testing.T) {
assert.Error(t, err)
assert.Nil(t, swarmSpec)
}
func TestConvertUpdateConfigOrder(t *testing.T) {
// test default behavior
updateConfig := convertUpdateConfig(&composetypes.UpdateConfig{})
assert.Equal(t, "", updateConfig.Order)
// test start-first
updateConfig = convertUpdateConfig(&composetypes.UpdateConfig{
Order: "start-first",
})
assert.Equal(t, updateConfig.Order, "start-first")
// test stop-first
updateConfig = convertUpdateConfig(&composetypes.UpdateConfig{
Order: "stop-first",
})
assert.Equal(t, updateConfig.Order, "stop-first")
}

View File

@ -31,6 +31,7 @@ services:
failure_action: continue
monitor: 60s
max_failure_ratio: 0.3
order: start-first
resources:
limits:
cpus: '0.001'

View File

@ -687,6 +687,7 @@ func TestFullExample(t *testing.T) {
FailureAction: "continue",
Monitor: time.Duration(60 * time.Second),
MaxFailureRatio: 0.3,
Order: "start-first",
},
Resources: types.Resources{
Limits: &types.Resource{

File diff suppressed because one or more lines are too long

View File

@ -339,7 +339,10 @@
"delay": {"type": "string", "format": "duration"},
"failure_action": {"type": "string"},
"monitor": {"type": "string", "format": "duration"},
"max_failure_ratio": {"type": "number"}
"max_failure_ratio": {"type": "number"},
"order": {"type": "string", "enum": [
"start-first", "stop-first"
]}
},
"additionalProperties": false
},

View File

@ -186,6 +186,7 @@ type UpdateConfig struct {
FailureAction string `mapstructure:"failure_action"`
Monitor time.Duration
MaxFailureRatio float32 `mapstructure:"max_failure_ratio"`
Order string
}
// Resources the resource limits and reservations