mirror of
https://github.com/offen/docker-volume-backup.git
synced 2024-11-10 00:30:29 +01:00
Add additional check if all containers have been removed
This commit is contained in:
parent
ba095ea753
commit
d0f3f41fe7
@ -478,6 +478,25 @@ func (s *script) stopContainersAndServices() (func() error, error) {
|
|||||||
} else {
|
} else {
|
||||||
scaledDownServices = append(scaledDownServices, service)
|
scaledDownServices = append(scaledDownServices, service)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// progress.ServiceProgress returns too early, so we need to manually check
|
||||||
|
// whether all containers belonging to the service have actually been removed
|
||||||
|
for {
|
||||||
|
containers, err := s.cli.ContainerList(context.Background(), types.ContainerListOptions{
|
||||||
|
Filters: filters.NewArgs(filters.KeyValuePair{
|
||||||
|
Key: "label",
|
||||||
|
Value: fmt.Sprintf("com.docker.swarm.service.id=%s", service.ID),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
scaleDownErrors = append(scaleDownErrors, err)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if len(containers) == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user