DockerCLI/cli/command/service
Sebastiaan van Stijn 678c2fde98
UX: don't reverse progress-bars when rolling back
Commit 330a003533
introduced "synchronous" service update and rollback, using progress bars to show
current status for each task.

As part of that change, progress bars were "reversed" when doing a rollback, to
indicate that status was rolled back to a previous state.

Reversing direction is somewhat confusing, as progress bars now return to their
"initial" state to indicate it was "completed"; for an "automatic" rollback, this
may be somewhat clear (progress bars "move to the right", then "roll back" if the
update failed), but when doing a manual rollback, it feels counter-intuitive
(rolling back is the _expected_ outcome).

This patch removes the code to reverse the direction of progress-bars, and makes
progress-bars always move from left ("start") to right ("finished").

Before this patch
----------------------------------------

1. create a service with automatic rollback on failure

    $ docker service create --update-failure-action=rollback --name foo --tty --replicas=5 nginx:alpine
    9xi1w3mv5sqtyexsuh78qg0cb
    overall progress: 5 out of 5 tasks
    1/5: running   [==================================================>]
    2/5: running   [==================================================>]
    3/5: running   [==================================================>]
    4/5: running   [==================================================>]
    5/5: running   [==================================================>]
    verify: Waiting 2 seconds to verify that tasks are stable...

2. update the service, making it fail after 3 seconds

    $ docker service update --entrypoint="/bin/sh -c 'sleep 3; exit 1'" foo
    overall progress: rolling back update: 2 out of 5 tasks
    1/5: running   [==================================================>]
    2/5: running   [==================================================>]
    3/5: starting  [============================================>      ]
    4/5: running   [==================================================>]
    5/5: running   [==================================================>]

3. Once the service starts failing, automatic rollback is started; progress-bars now move in the reverse direction;

    overall progress: rolling back update: 3 out of 5 tasks
    1/5: ready     [===========>                                       ]
    2/5: ready     [===========>                                       ]
    3/5: running   [>                                                  ]
    4/5: running   [>                                                  ]
    5/5: running   [>                                                  ]

4. When the rollback is completed, the progressbars are at the "start" to indicate they completed;

    overall progress: rolling back update: 5 out of 5 tasks
    1/5: running   [>                                                  ]
    2/5: running   [>                                                  ]
    3/5: running   [>                                                  ]
    4/5: running   [>                                                  ]
    5/5: running   [>                                                  ]
    rollback: update rolled back due to failure or early termination of task bndiu8a998agr8s6sjlg9tnrw
    verify: Service converged

After this patch
----------------------------------------

Progress bars always go from left to right; also in a rollback situation;

After updating to the "faulty" entrypoint, task are deployed:

    $ docker service update --entrypoint="/bin/sh -c 'sleep 3; exit 1'" foo
    foo
    overall progress: 1 out of 5 tasks
    1/5:
    2/5: running   [==================================================>]
    3/5: ready     [======================================>            ]
    4/5:
    5/5:

Once tasks start failing, rollback is started, and presented the same as a regular
update; progress bars go from left to right;

    overall progress: rolling back update: 3 out of 5 tasks
    1/5: ready     [======================================>            ]
    2/5: starting  [============================================>      ]
    3/5: running   [==================================================>]
    4/5: running   [==================================================>]
    5/5: running   [==================================================>]
    rollback: update rolled back due to failure or early termination of task c11dxd7ud3d5pq8g45qkb4rjx

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-06-22 10:28:46 +02:00
..
progress UX: don't reverse progress-bars when rolling back 2021-06-22 10:28:46 +02:00
testdata Add support for --limit-pids on service create / update (swarm) 2020-06-18 21:25:02 +02:00
client_test.go service: remove unused opts from newService() (unparam) 2019-10-31 19:22:43 +01:00
cmd.go Error out on orchestrator command that don't support k8s yet 2017-12-26 11:46:59 +01:00
create.go Add ulimits option to docker service create/update/inspect 2020-09-10 14:41:33 +02:00
create_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00
formatter.go Add ulimits option to docker service create/update/inspect 2020-09-10 14:41:33 +02:00
formatter_test.go formatter: reduce minimum width for columns in table-view 2020-08-31 16:31:15 +02:00
generic_resource_opts.go Added support for generic resource update 2017-11-28 18:03:10 +01:00
generic_resource_opts_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00
helpers.go Switch from x/net/context to context 2018-05-11 16:49:43 -07:00
inspect.go formatter package heavy refactoring 2018-10-23 17:05:44 +02:00
inspect_test.go Add support for --limit-pids on service create / update (swarm) 2020-06-18 21:25:02 +02:00
list.go Add jobs support to CLI 2020-04-24 11:22:10 -05:00
list_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00
logs.go fix docs, completion and docker service 2020-08-06 17:37:08 +03:00
opts.go fix --update-order and --rollback-order flags 2021-01-18 22:33:45 +08:00
opts_test.go fix --update-order and --rollback-order flags 2021-01-18 22:33:45 +08:00
parse.go Add CredentialSpec tests 2019-04-12 11:17:34 -05:00
ps.go Migrate to non-deprecated functions of `api/types/filters` 2018-07-27 15:37:43 +02:00
ps_test.go bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-23 00:28:55 +01:00
remove.go Switch from x/net/context to context 2018-05-11 16:49:43 -07:00
rollback.go Update code for upstream cobra 2017-10-25 14:49:26 -04:00
rollback_test.go Replace deprecated Cobra command.SetOutput() with command.SetOut() 2020-05-07 14:25:59 +02:00
scale.go Add jobs support to CLI 2020-04-24 11:22:10 -05:00
trust.go Switch from x/net/context to context 2018-05-11 16:49:43 -07:00
update.go Fix 2 typos 2020-09-18 09:26:39 -06:00
update_test.go Fix 2 typos 2020-09-18 09:26:39 -06:00