Fix multus-daemon quit process (#1133)

This commit is contained in:
Tomofumi Hayashi
2023-08-04 01:16:37 +09:00
committed by GitHub
parent 46d446f0e5
commit d5883bdbfa
2 changed files with 10 additions and 10 deletions

View File

@@ -167,15 +167,8 @@ func main() {
}() }()
} }
wg.Add(1)
go func() {
<-serverDoneChannel
logging.Verbosef("multus-server done.")
wg.Done()
}()
wg.Wait() wg.Wait()
// never reached logging.Verbosef("multus daemon is exited")
} }
func waitUntilAPIReady(socketPath string) error { 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)) utilruntime.HandleError(fmt.Errorf("CNI server Serve() failed: %v", err))
} }
}, 0) }, 0)
}()
go func() {
<-ctx.Done()
server.Shutdown(context.Background()) server.Shutdown(context.Background())
close(done)
}() }()
return nil return nil

View File

@@ -217,6 +217,7 @@ func (m *Manager) MonitorPluginConfiguration(ctx context.Context, done chan<- st
case <-ctx.Done(): case <-ctx.Done():
logging.Verbosef("Stopped monitoring, closing channel ...") logging.Verbosef("Stopped monitoring, closing channel ...")
_ = m.configWatcher.Close() _ = m.configWatcher.Close()
close(done)
return nil 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 // PersistMultusConfig persists the provided configuration to the disc, with
// Read / Write permissions. The output file path is `<multus auto config dir>/00-multus.conf` // Read / Write permissions. The output file path is `<multus auto config dir>/00-multus.conf`
func (m *Manager) PersistMultusConfig(config string) (string, error) { func (m *Manager) PersistMultusConfig(config string) (string, error) {
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) logging.Debugf("Writing Multus CNI configuration @ %s", m.multusConfigFilePath)
}
return m.multusConfigFilePath, os.WriteFile(m.multusConfigFilePath, []byte(config), UserRWPermission) return m.multusConfigFilePath, os.WriteFile(m.multusConfigFilePath, []byte(config), UserRWPermission)
} }