From 32fbb846d8cb18fd436b31756365650b617c5cc3 Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Wed, 5 Aug 2026 14:54:08 +0300 Subject: [PATCH] resmgr: force a cache save after CreateContainer. Force a cache save after CreateContainer, ensuring its state gets updated to Created on disk, too. Failing to do so could leave the last created container in the synthetic Creating state which is ignored during startup. This in turn could cause the last container to not get properly reallocated if the policy gets restarted or crashes. Signed-off-by: Krisztian Litkey --- pkg/resmgr/nri.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/resmgr/nri.go b/pkg/resmgr/nri.go index afd9698b5..32be35c99 100644 --- a/pkg/resmgr/nri.go +++ b/pkg/resmgr/nri.go @@ -453,6 +453,13 @@ func (p *nriPlugin) CreateContainer(ctx context.Context, pod *api.PodSandbox, co m.Lock() defer m.Unlock() + m.cache.BlockSave() + defer func() { + if err := m.cache.UnblockSave(); err != nil { + nri.Errorf("failed to unblock cache save: %v", err) + } + }() + c, err := m.cache.InsertContainer(container, cache.WithContainerState(cache.ContainerStateCreating)) if err != nil { return nil, nil, fmt.Errorf("failed to cache container: %w", err)