mirror of
https://github.com/k8snetworkplumbingwg/multus-cni.git
synced 2025-09-19 08:25:18 +00:00
Fix multus-daemon quit process (#1133)
This commit is contained in:
@@ -167,15 +167,8 @@ func main() {
|
||||
}()
|
||||
}
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
<-serverDoneChannel
|
||||
logging.Verbosef("multus-server done.")
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
wg.Wait()
|
||||
// never reached
|
||||
logging.Verbosef("multus daemon is exited")
|
||||
}
|
||||
|
||||
func waitUntilAPIReady(socketPath string) error {
|
||||
@@ -223,8 +216,10 @@ func startMultusDaemon(ctx context.Context, daemonConfig *srv.ControllerNetConf,
|
||||
utilruntime.HandleError(fmt.Errorf("CNI server Serve() failed: %v", err))
|
||||
}
|
||||
}, 0)
|
||||
}()
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
server.Shutdown(context.Background())
|
||||
close(done)
|
||||
}()
|
||||
|
||||
return nil
|
||||
|
@@ -217,6 +217,7 @@ func (m *Manager) MonitorPluginConfiguration(ctx context.Context, done chan<- st
|
||||
case <-ctx.Done():
|
||||
logging.Verbosef("Stopped monitoring, closing channel ...")
|
||||
_ = m.configWatcher.Close()
|
||||
close(done)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -225,7 +226,11 @@ func (m *Manager) MonitorPluginConfiguration(ctx context.Context, done chan<- st
|
||||
// PersistMultusConfig persists the provided configuration to the disc, with
|
||||
// Read / Write permissions. The output file path is `<multus auto config dir>/00-multus.conf`
|
||||
func (m *Manager) PersistMultusConfig(config string) (string, error) {
|
||||
logging.Debugf("Writing Multus CNI configuration @ %s", m.multusConfigFilePath)
|
||||
if _, err := os.Stat(m.multusConfigFilePath); err == nil {
|
||||
logging.Debugf("Overwriting Multus CNI configuration @ %s", m.multusConfigFilePath)
|
||||
} else {
|
||||
logging.Debugf("Writing Multus CNI configuration @ %s", m.multusConfigFilePath)
|
||||
}
|
||||
return m.multusConfigFilePath, os.WriteFile(m.multusConfigFilePath, []byte(config), UserRWPermission)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user