Skip to content

Commit 62f98a1

Browse files
committed
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 <[email protected]>
1 parent e735405 commit 62f98a1

4 files changed

Lines changed: 27 additions & 11 deletions

File tree

pkg/cri/sbserver/service.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,17 @@ func (c *criService) Run() error {
260260
netSyncGroup.Done()
261261
}(h)
262262
}
263-
go func() {
264-
netSyncGroup.Wait()
265-
close(cniNetConfMonitorErrCh)
266-
}()
263+
// For platforms that may not support CNI (darwin etc.) there's no
264+
// use in launching this as `Wait` will return immediately. Further
265+
// down we select on this channel along with some others to determine
266+
// if we should Close() the CRI service, so closing this preemptively
267+
// isn't good.
268+
if len(c.cniNetConfMonitor) > 0 {
269+
go func() {
270+
netSyncGroup.Wait()
271+
close(cniNetConfMonitorErrCh)
272+
}()
273+
}
267274

268275
// Start streaming server.
269276
logrus.Info("Start streaming server")

pkg/cri/sbserver/service_other.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ import (
2222
"github.com/containerd/go-cni"
2323
)
2424

25-
// initPlatform handles linux specific initialization for the CRI service.
25+
// initPlatform handles initialization of the CRI service for non-windows
26+
// and non-linux platforms.
2627
func (c *criService) initPlatform() error {
2728
return nil
2829
}
2930

30-
// cniLoadOptions returns cni load options for the linux.
31+
// cniLoadOptions returns cni load options for non-windows and non-linux
32+
// platforms.
3133
func (c *criService) cniLoadOptions() []cni.Opt {
3234
return []cni.Opt{}
3335
}

pkg/cri/sbserver/service_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
// attaches to
2727
const windowsNetworkAttachCount = 1
2828

29-
// initPlatform handles linux specific initialization for the CRI service.
29+
// initPlatform handles windows specific initialization for the CRI service.
3030
func (c *criService) initPlatform() error {
3131
pluginDirs := map[string]string{
3232
defaultNetworkPlugin: c.config.NetworkPluginConfDir,

pkg/cri/server/service.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,17 @@ func (c *criService) Run() error {
237237
netSyncGroup.Done()
238238
}(h)
239239
}
240-
go func() {
241-
netSyncGroup.Wait()
242-
close(cniNetConfMonitorErrCh)
243-
}()
240+
// For platforms that may not support CNI (darwin etc.) there's no
241+
// use in launching this as `Wait` will return immediately. Further
242+
// down we select on this channel along with some others to determine
243+
// if we should Close() the CRI service, so closing this preemptively
244+
// isn't good.
245+
if len(c.cniNetConfMonitor) > 0 {
246+
go func() {
247+
netSyncGroup.Wait()
248+
close(cniNetConfMonitorErrCh)
249+
}()
250+
}
244251

245252
// Start streaming server.
246253
logrus.Info("Start streaming server")

0 commit comments

Comments
 (0)