From 1fdf84b8e9bf92b08971c6960cc8fe4386c23988 Mon Sep 17 00:00:00 2001 From: Jim Lin Date: Mon, 18 Jan 2021 22:33:45 +0800 Subject: [PATCH] fix --update-order and --rollback-order flags Signed-off-by: Jim Lin (cherry picked from commit 26a6a724aacb9def52e4ecbc2259fca131cf6c12) Signed-off-by: Sebastiaan van Stijn --- cli/command/service/opts.go | 4 ++-- cli/command/service/opts_test.go | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cli/command/service/opts.go b/cli/command/service/opts.go index b8b6873a0b..020e9dd015 100644 --- a/cli/command/service/opts.go +++ b/cli/command/service/opts.go @@ -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 } @@ -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 } diff --git a/cli/command/service/opts_test.go b/cli/command/service/opts_test.go index c89948ad39..7d014a02e6 100644 --- a/cli/command/service/opts_test.go +++ b/cli/command/service/opts_test.go @@ -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",