From acc307b422c58970dd6e809702e60cce974eee96 Mon Sep 17 00:00:00 2001 From: Iceber Gu Date: Thu, 18 May 2023 14:18:01 +0800 Subject: [PATCH] sync sandboxes and containers after starting the pre-installed plugins Signed-off-by: Iceber Gu --- pkg/adaptation/adaptation.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pkg/adaptation/adaptation.go b/pkg/adaptation/adaptation.go index 9201e641..aa9a6a2a 100644 --- a/pkg/adaptation/adaptation.go +++ b/pkg/adaptation/adaptation.go @@ -346,12 +346,27 @@ func (r *Adaptation) startPlugins() (retErr error) { } if err := p.start(r.name, r.version); err != nil { - return err + return fmt.Errorf("failed to start NRI Plugin %q: %w", name, err) } plugins = append(plugins, p) } + syncPlugins := func(ctx context.Context, pods []*PodSandbox, containers []*Container) ([]*ContainerUpdate, error) { + var updates []*ContainerUpdate + for _, plugin := range plugins { + us, err := plugin.synchronize(ctx, pods, containers) + if err != nil { + return nil, fmt.Errorf("failed to sync NRI Plugin %q: %w", plugin.name(), err) + } + updates = append(updates, us...) + } + return updates, nil + } + if err := r.syncFn(noCtx, syncPlugins); err != nil { + return fmt.Errorf("failed to synchronize NRI Plugins: %w", err) + } + r.plugins = plugins r.sortPlugins()