CRI: Don't always close netConfMonitor channel

In the CRI server initialization a syncgroup is setup that adds to the
counter for every cni config found/registered. This functions on platforms
where CNI is supported/theres an assumption that there will always be
the loopback config. However, on platforms like Darwin where there's generally
nothing registered the Wait() on the syncgroup returns immediately and the
channel used to return any Network config sync errors is closed. This channel
is one of three that's used to monitor if we should Close the CRI service in
containerd, so it's not great if this happens.

Signed-off-by: Danny Canter <danny@dcantah.dev>
This commit is contained in:
Danny Canter
2023-03-15 19:50:11 -07:00
parent e735405c15
commit 62f98a1c11
4 changed files with 27 additions and 11 deletions

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")