Skip to content

Commit

Permalink
Merge pull request #2927 from jimlinntu/fix_update_rollback_order
Browse files Browse the repository at this point in the history
fix --update-order and --rollback-order flags
  • Loading branch information
thaJeztah authored Jan 18, 2021
2 parents 35f023a + 26a6a72 commit a49d70c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cli/command/service/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func updateConfigFromDefaults(defaultUpdateConfig *api.UpdateConfig) *swarm.Upda
}

func (opts updateOptions) updateConfig(flags *pflag.FlagSet) *swarm.UpdateConfig {
if !anyChanged(flags, flagUpdateParallelism, flagUpdateDelay, flagUpdateMonitor, flagUpdateFailureAction, flagUpdateMaxFailureRatio) {
if !anyChanged(flags, flagUpdateParallelism, flagUpdateDelay, flagUpdateMonitor, flagUpdateFailureAction, flagUpdateMaxFailureRatio, flagUpdateOrder) {
return nil
}

Expand Down Expand Up @@ -194,7 +194,7 @@ func (opts updateOptions) updateConfig(flags *pflag.FlagSet) *swarm.UpdateConfig
}

func (opts updateOptions) rollbackConfig(flags *pflag.FlagSet) *swarm.UpdateConfig {
if !anyChanged(flags, flagRollbackParallelism, flagRollbackDelay, flagRollbackMonitor, flagRollbackFailureAction, flagRollbackMaxFailureRatio) {
if !anyChanged(flags, flagRollbackParallelism, flagRollbackDelay, flagRollbackMonitor, flagRollbackFailureAction, flagRollbackMaxFailureRatio, flagRollbackOrder) {
return nil
}

Expand Down
16 changes: 16 additions & 0 deletions cli/command/service/opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,22 @@ func TestToServiceUpdateRollback(t *testing.T) {
assert.Check(t, is.DeepEqual(service.RollbackConfig, expected.RollbackConfig))
}

func TestToServiceUpdateRollbackOrder(t *testing.T) {
flags := newCreateCommand(nil).Flags()
flags.Set("update-order", "start-first")
flags.Set("rollback-order", "start-first")

o := newServiceOptions()
o.mode = "replicated"
o.update = updateOptions{order: "start-first"}
o.rollback = updateOptions{order: "start-first"}

service, err := o.ToService(context.Background(), &fakeClient{}, flags)
assert.NilError(t, err)
assert.Check(t, is.Equal(service.UpdateConfig.Order, o.update.order))
assert.Check(t, is.Equal(service.RollbackConfig.Order, o.rollback.order))
}

func TestToServiceMaxReplicasGlobalModeConflict(t *testing.T) {
opt := serviceOptions{
mode: "global",
Expand Down

0 comments on commit a49d70c

Please sign in to comment.