Log warnings from Docker when updating services

This commit is contained in:
Frederik Ring 2024-01-27 12:32:06 +01:00
parent 94aa33369f
commit 78a89c1a93

View File

@ -441,9 +441,16 @@ func (s *script) stopContainersAndServices() (func() error, error) {
continue 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 { if err != nil {
scaleDownErrors = append(scaleDownErrors, err) 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 { 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 service.Spec.Mode.Replicated.Replicas = &svc.initialReplicaCount
if _, err := s.cli.ServiceUpdate( response, err := s.cli.ServiceUpdate(
context.Background(), context.Background(),
service.ID, service.ID,
service.Version, service.Spec, service.Version, service.Spec,
types.ServiceUpdateOptions{}, types.ServiceUpdateOptions{},
); err != nil { )
if err != nil {
scaleUpErrors = append(scaleUpErrors, err) 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 { if err := progress.ServiceProgress(context.Background(), s.cli, service.ID, discardWriter); err != nil {
scaleUpErrors = append(scaleUpErrors, err) scaleUpErrors = append(scaleUpErrors, err)