Merge pull request #8277 from dcantah/netconf-cni-fix

CRI: Don't always close netConfMonitor channel
This commit is contained in:
Fu Wei 2023-03-16 17:05:48 +08:00 committed by GitHub
commit 2f4f015e5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 11 deletions

View File

@ -260,10 +260,17 @@ func (c *criService) Run() error {
netSyncGroup.Done()
}(h)
}
go func() {
netSyncGroup.Wait()
close(cniNetConfMonitorErrCh)
}()
// For platforms that may not support CNI (darwin etc.) there's no
// use in launching this as `Wait` will return immediately. Further
// down we select on this channel along with some others to determine
// if we should Close() the CRI service, so closing this preemptively
// isn't good.
if len(c.cniNetConfMonitor) > 0 {
go func() {
netSyncGroup.Wait()
close(cniNetConfMonitorErrCh)
}()
}
// Start streaming server.
logrus.Info("Start streaming server")

View File

@ -22,12 +22,14 @@ import (
"github.com/containerd/go-cni"
)
// initPlatform handles linux specific initialization for the CRI service.
// initPlatform handles initialization of the CRI service for non-windows
// and non-linux platforms.
func (c *criService) initPlatform() error {
return nil
}
// cniLoadOptions returns cni load options for the linux.
// cniLoadOptions returns cni load options for non-windows and non-linux
// platforms.
func (c *criService) cniLoadOptions() []cni.Opt {
return []cni.Opt{}
}

View File

@ -26,7 +26,7 @@ import (
// attaches to
const windowsNetworkAttachCount = 1
// initPlatform handles linux specific initialization for the CRI service.
// initPlatform handles windows specific initialization for the CRI service.
func (c *criService) initPlatform() error {
pluginDirs := map[string]string{
defaultNetworkPlugin: c.config.NetworkPluginConfDir,

View File

@ -237,10 +237,17 @@ func (c *criService) Run() error {
netSyncGroup.Done()
}(h)
}
go func() {
netSyncGroup.Wait()
close(cniNetConfMonitorErrCh)
}()
// For platforms that may not support CNI (darwin etc.) there's no
// use in launching this as `Wait` will return immediately. Further
// down we select on this channel along with some others to determine
// if we should Close() the CRI service, so closing this preemptively
// isn't good.
if len(c.cniNetConfMonitor) > 0 {
go func() {
netSyncGroup.Wait()
close(cniNetConfMonitorErrCh)
}()
}
// Start streaming server.
logrus.Info("Start streaming server")