cri,nri: block NRI plugin sync. during event processing.

Block the synchronization of registering NRI plugins during
CRI events to avoid the plugin ending up in an inconsistent
starting state after initial sync (missing pods, containers
or missed events for some pods or containers).

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
This commit is contained in:
Krisztian Litkey
2025-01-31 20:15:12 +02:00
parent e465b45f9c
commit 79cdbf61b6
11 changed files with 49 additions and 0 deletions

View File

@@ -81,6 +81,9 @@ type API interface {
// RemoveContainer relays container removal events to NRI.
RemoveContainer(context.Context, PodSandbox, Container) error
// BlockPluginSync blocks plugin synchronization until it is Unblock()ed.
BlockPluginSync() *PluginSyncBlock
}
type State int
@@ -435,6 +438,15 @@ func (l *local) RemoveContainer(ctx context.Context, pod PodSandbox, ctr Contain
return err
}
type PluginSyncBlock = nri.PluginSyncBlock
func (l *local) BlockPluginSync() *PluginSyncBlock {
if !l.IsEnabled() {
return nil
}
return l.nri.BlockPluginSync()
}
func (l *local) syncPlugin(ctx context.Context, syncFn nri.SyncCB) error {
l.Lock()
defer l.Unlock()