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 <fgiudici@redhat.com>
This commit is contained in:
Francesco Giudici 2022-02-23 11:21:06 +01:00
parent 160bb62138
commit 3ac52e8193

View File

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