From b1a23c495a77fa88ec43d91ce8541e3596901ac5 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Mon, 3 Jun 2024 17:08:18 -0700 Subject: [PATCH] Fail integration test early when a plugin load fails Avoid running tests when a plugin fails to load and return the init error from the plugin. This prevents the test failing later with an unhelpful error and attempting to find the actual error in the daemon logs. Signed-off-by: Derek McGowan --- integration/client/daemon.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/integration/client/daemon.go b/integration/client/daemon.go index 1843eb8a6..fe57c6c7b 100644 --- a/integration/client/daemon.go +++ b/integration/client/daemon.go @@ -23,10 +23,13 @@ import ( "io" "os/exec" "runtime" + "strings" "sync" "syscall" "time" + "github.com/containerd/plugin" + . "github.com/containerd/containerd/v2/client" ) @@ -79,6 +82,21 @@ func (d *daemon) waitForStart(ctx context.Context) (*Client, error) { } continue } + resp, perr := client.IntrospectionService().Plugins(ctx) + if perr != nil { + return nil, fmt.Errorf("failed to get plugin list: %w", perr) + } + var loadErr error + for _, p := range resp.Plugins { + if p.InitErr != nil && !strings.Contains(p.InitErr.Message, plugin.ErrSkipPlugin.Error()) { + pluginErr := fmt.Errorf("failed to load %s.%s: %s", p.Type, p.ID, p.InitErr.Message) + loadErr = errors.Join(loadErr, pluginErr) + } + } + if loadErr != nil { + return nil, loadErr + } + return client, err case <-ctx.Done(): return nil, fmt.Errorf("context deadline exceeded: %w", err)