Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: [iceber] /sync pre installed plugins #6

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions pkg/adaptation/adaptation.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,40 @@ 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)
}

// 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 (
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 {
plugin.stop()
errs = append(errs, fmt.Errorf("[%s] %w", plugin.name(), err))
} else {
plugins = append(plugins, plugin)
updates = append(updates, us...)
}
}
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
Loading