Don't log an error when stopping the container if it is not running.

This removes a lot of confusing messages from the test logs.

PiperOrigin-RevId: 266164001
This commit is contained in:
Nicolas Lacasse
2019-08-29 14:00:18 -07:00
parent 599136b25e
commit 6e8fc27dc5
+5 -1
View File
@@ -297,7 +297,11 @@ func (d *Docker) Remove() error {
func (d *Docker) CleanUp() {
d.logDockerID()
if _, err := do("kill", d.Name); err != nil {
log.Printf("error killing container %q: %v", d.Name, err)
if strings.Contains(err.Error(), "is not running") {
// Nothing to kill. Don't log the error in this case.
} else {
log.Printf("error killing container %q: %v", d.Name, err)
}
}
if err := d.Remove(); err != nil {
log.Print(err)