Skip to content

Commit 680691c

Browse files
authored
Merge pull request #1138 from pendo324/wait-for-network-daemon-stop
pkg/networks: wait for daemon to stop after killing
2 parents e2652c5 + cb270ce commit 680691c

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

pkg/networks/reconcile/reconcile.go

+11-12
Original file line numberDiff line numberDiff line change
@@ -226,19 +226,18 @@ func stopNetwork(config *networks.YAML, name string) error {
226226
return err
227227
}
228228
}
229-
// wait for VMNet to terminate (up to 5s) before stopping Switch, otherwise the socket may not get deleted
230-
if daemon == networks.VDEVMNet {
231-
startWaiting := time.Now()
232-
for {
233-
if pid, _ := store.ReadPIDFile(config.PIDFile(name, daemon)); pid == 0 {
234-
break
235-
}
236-
if time.Since(startWaiting) > 5*time.Second {
237-
logrus.Infof("%q daemon for %q network still running after 5 seconds", daemon, name)
238-
break
239-
}
240-
time.Sleep(500 * time.Millisecond)
229+
// wait for daemons to terminate (up to 5s) before stopping, otherwise the sockets may not get deleted which
230+
// will cause subsequent start commands to fail.
231+
startWaiting := time.Now()
232+
for {
233+
if pid, _ := store.ReadPIDFile(config.PIDFile(name, daemon)); pid == 0 {
234+
break
241235
}
236+
if time.Since(startWaiting) > 5*time.Second {
237+
logrus.Infof("%q daemon for %q network still running after 5 seconds", daemon, name)
238+
break
239+
}
240+
time.Sleep(500 * time.Millisecond)
242241
}
243242
}
244243
return nil

0 commit comments

Comments
 (0)