mirror of
https://github.com/offen/docker-volume-backup.git
synced 2024-11-22 05:10:28 +01:00
Result of query for services is used before handling possible error (#405)
* Result of query for services is used before handling possible error * Return early when a non-replicated service is matched
This commit is contained in:
parent
bf79c913e0
commit
8b69566291
@ -151,15 +151,21 @@ func (s *script) stopContainersAndServices() (func() error, error) {
|
|||||||
}),
|
}),
|
||||||
Status: true,
|
Status: true,
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
return noop, errwrap.Wrap(err, "error querying for services to scale down")
|
||||||
|
}
|
||||||
for _, s := range matchingServices {
|
for _, s := range matchingServices {
|
||||||
|
if s.Spec.Mode.Replicated == nil {
|
||||||
|
return noop, errwrap.Wrap(
|
||||||
|
nil,
|
||||||
|
fmt.Sprintf("only replicated services can be restarted, but found a label on service %s", s.Spec.Name),
|
||||||
|
)
|
||||||
|
}
|
||||||
servicesToScaleDown = append(servicesToScaleDown, handledSwarmService{
|
servicesToScaleDown = append(servicesToScaleDown, handledSwarmService{
|
||||||
serviceID: s.ID,
|
serviceID: s.ID,
|
||||||
initialReplicaCount: *s.Spec.Mode.Replicated.Replicas,
|
initialReplicaCount: *s.Spec.Mode.Replicated.Replicas,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
return noop, errwrap.Wrap(err, "error querying for services to scale down")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(containersToStop) == 0 && len(servicesToScaleDown) == 0 {
|
if len(containersToStop) == 0 && len(servicesToScaleDown) == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user