From a430772e299b9a2959f89c7d26dba14fa2e73e83 Mon Sep 17 00:00:00 2001 From: Frederik Ring Date: Sat, 27 Jan 2024 12:32:06 +0100 Subject: [PATCH] Log warnings from Docker when updating services --- cmd/backup/script.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/cmd/backup/script.go b/cmd/backup/script.go index 1759eb5..287eaaf 100644 --- a/cmd/backup/script.go +++ b/cmd/backup/script.go @@ -441,9 +441,16 @@ func (s *script) stopContainersAndServices() (func() error, error) { continue } - _, err = s.cli.ServiceUpdate(context.Background(), service.ID, service.Version, service.Spec, types.ServiceUpdateOptions{}) + response, err := s.cli.ServiceUpdate(context.Background(), service.ID, service.Version, service.Spec, types.ServiceUpdateOptions{}) if err != nil { scaleDownErrors = append(scaleDownErrors, err) + continue + } + + for _, warning := range response.Warnings { + s.logger.Warn( + fmt.Sprintf("The Docker API returned a warning when scaling down service %s: %s", service.Spec.Name, warning), + ) } if err := progress.ServiceProgress(context.Background(), s.cli, service.ID, discardWriter); err != nil { @@ -529,13 +536,20 @@ func (s *script) stopContainersAndServices() (func() error, error) { } service.Spec.Mode.Replicated.Replicas = &svc.initialReplicaCount - if _, err := s.cli.ServiceUpdate( + response, err := s.cli.ServiceUpdate( context.Background(), service.ID, service.Version, service.Spec, types.ServiceUpdateOptions{}, - ); err != nil { + ) + if err != nil { scaleUpErrors = append(scaleUpErrors, err) + continue + } + for _, warning := range response.Warnings { + s.logger.Warn( + fmt.Sprintf("The Docker API returned a warning when scaling up service %s: %s", service.Spec.Name, warning), + ) } if err := progress.ServiceProgress(context.Background(), s.cli, service.ID, discardWriter); err != nil { scaleUpErrors = append(scaleUpErrors, err)