From 58d3fc24b188c7cb5eff8ceee61d340e27b19aae Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Fri, 30 Jun 2017 12:04:49 +0200 Subject: [PATCH] scale all services at once Signed-off-by: Victor Vieux --- cli/command/service/scale.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/cli/command/service/scale.go b/cli/command/service/scale.go index 7a23a26626..f58786156a 100644 --- a/cli/command/service/scale.go +++ b/cli/command/service/scale.go @@ -56,6 +56,7 @@ func scaleArgs(cmd *cobra.Command, args []string) error { func runScale(dockerCli *command.DockerCli, flags *pflag.FlagSet, options *scaleOptions, args []string) error { var errs []string + var serviceIDs []string ctx := context.Background() for _, arg := range args { @@ -71,19 +72,22 @@ func runScale(dockerCli *command.DockerCli, flags *pflag.FlagSet, options *scale if err := runServiceScale(ctx, dockerCli, serviceID, scale); err != nil { errs = append(errs, fmt.Sprintf("%s: %v", serviceID, err)) + } else { + serviceIDs = append(serviceIDs, serviceID) } - if options.detach { - continue - } - - if err := waitOnService(ctx, dockerCli, serviceID, false); err != nil { - errs = append(errs, fmt.Sprintf("%s: %v", serviceID, err)) - } } - if options.detach { - warnDetachDefault(dockerCli.Err(), dockerCli.Client().ClientVersion(), flags, "scaled") + if len(serviceIDs) > 0 { + if options.detach { + warnDetachDefault(dockerCli.Err(), dockerCli.Client().ClientVersion(), flags, "scaled") + } else { + for _, serviceID := range serviceIDs { + if err := waitOnService(ctx, dockerCli, serviceID, false); err != nil { + errs = append(errs, fmt.Sprintf("%s: %v", serviceID, err)) + } + } + } } if len(errs) == 0 {