From 3ac52e81937cf0fe1cbbb4b2cb1b4132e7030877 Mon Sep 17 00:00:00 2001 From: Francesco Giudici Date: Wed, 23 Feb 2022 11:21:06 +0100 Subject: [PATCH] kata-monitor: fix updating sandbox cache at startup We now rely on fs events only to update the sandbox cache. This is not true anyway for sandboxes already present at kata-monitor startup: we just retrieve the list and add them in the cache only when we get their CRI metadata. If CRI metadata is not available we will never add them to the sandbox cache. Fix this by immediately adding the sandboxes we find at startup time to the sandbox cache. Fixes: #3705 Signed-off-by: Francesco Giudici --- src/runtime/pkg/kata-monitor/monitor.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/runtime/pkg/kata-monitor/monitor.go b/src/runtime/pkg/kata-monitor/monitor.go index caacfb222..4a1a2d2f5 100644 --- a/src/runtime/pkg/kata-monitor/monitor.go +++ b/src/runtime/pkg/kata-monitor/monitor.go @@ -104,6 +104,10 @@ func (km *KataMonitor) startPodCacheUpdater() { monitorLog.WithError(err).Fatal("cannot read sandboxes fs") os.Exit(1) } + for _, sandbox := range sandboxList { + km.sandboxCache.putIfNotExists(sandbox, sandboxKubeData{}) + } + monitorLog.Debug("initial sync of sbs directory completed") monitorLog.Tracef("pod list from sbs: %v", sandboxList)