From 78a89c1a93a2d5db70d473ce54c1d65f681ac90c 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)