Skip to content

Commit

Permalink
ignore pre-installed plugins that did not sync successfully
Browse files Browse the repository at this point in the history
Signed-off-by: Iceber Gu <[email protected]>
  • Loading branch information
Iceber authored and klihub committed Jun 4, 2024
1 parent 4b3258a commit 453f5de
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions pkg/adaptation/adaptation.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,24 +352,34 @@ func (r *Adaptation) startPlugins() (retErr error) {
plugins = append(plugins, p)
}

// Although the error returned by syncPlugins may not be nil, r.syncFn could still ignores this error and returns a nil error.
// We need to make sure that the plugins are successfully synchronized in the `plugins`
syncPlugins := func(ctx context.Context, pods []*PodSandbox, containers []*Container) ([]*ContainerUpdate, error) {
var updates []*ContainerUpdate
for _, plugin := range plugins {
var (
errs []error
updates []*ContainerUpdate
)

startedPlugins := plugins
plugins = make([]*plugin, 0, len(plugins))
for _, plugin := range startedPlugins {
us, err := plugin.synchronize(ctx, pods, containers)
if err != nil {
return nil, fmt.Errorf("failed to sync NRI Plugin %q: %w", plugin.name(), err)
plugin.stop()
errs = append(errs, fmt.Errorf("[%s] %w", plugin.name(), err))
} else {
plugins = append(plugins, plugin)
updates = append(updates, us...)
}
updates = append(updates, us...)
}
return updates, nil
return updates, errors.Join(errs...)
}
if err := r.syncFn(noCtx, syncPlugins); err != nil {
return fmt.Errorf("failed to synchronize NRI Plugins: %w", err)
}

r.plugins = plugins
r.sortPlugins()

return nil
}

Expand Down

0 comments on commit 453f5de

Please sign in to comment.