Skip to content

Commit

Permalink
Merge pull request #1138 from pendo324/wait-for-network-daemon-stop
Browse files Browse the repository at this point in the history
pkg/networks: wait for daemon to stop after killing
  • Loading branch information
AkihiroSuda authored Nov 2, 2022
2 parents e2652c5 + cb270ce commit 680691c
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions pkg/networks/reconcile/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,18 @@ func stopNetwork(config *networks.YAML, name string) error {
return err
}
}
// wait for VMNet to terminate (up to 5s) before stopping Switch, otherwise the socket may not get deleted
if daemon == networks.VDEVMNet {
startWaiting := time.Now()
for {
if pid, _ := store.ReadPIDFile(config.PIDFile(name, daemon)); pid == 0 {
break
}
if time.Since(startWaiting) > 5*time.Second {
logrus.Infof("%q daemon for %q network still running after 5 seconds", daemon, name)
break
}
time.Sleep(500 * time.Millisecond)
// wait for daemons to terminate (up to 5s) before stopping, otherwise the sockets may not get deleted which
// will cause subsequent start commands to fail.
startWaiting := time.Now()
for {
if pid, _ := store.ReadPIDFile(config.PIDFile(name, daemon)); pid == 0 {
break
}
if time.Since(startWaiting) > 5*time.Second {
logrus.Infof("%q daemon for %q network still running after 5 seconds", daemon, name)
break
}
time.Sleep(500 * time.Millisecond)
}
}
return nil
Expand Down

0 comments on commit 680691c

Please sign in to comment.