Skip to content

Commit 40012b6

Browse files
committed
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 <[email protected]> (cherry picked from commit b1a23c4) Signed-off-by: Derek McGowan <[email protected]>
1 parent 2b6d2e9 commit 40012b6

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

integration/client/daemon.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ import (
2323
"io"
2424
"os/exec"
2525
"runtime"
26+
"strings"
2627
"sync"
2728
"syscall"
2829
"time"
2930

3031
. "github.com/containerd/containerd"
32+
"github.com/containerd/containerd/plugin"
3133
)
3234

3335
type daemon struct {
@@ -79,6 +81,21 @@ func (d *daemon) waitForStart(ctx context.Context) (*Client, error) {
7981
}
8082
continue
8183
}
84+
resp, perr := client.IntrospectionService().Plugins(ctx, nil)
85+
if perr != nil {
86+
return nil, fmt.Errorf("failed to get plugin list: %w", perr)
87+
}
88+
var loadErr error
89+
for _, p := range resp.Plugins {
90+
if p.InitErr != nil && !strings.Contains(p.InitErr.Message, plugin.ErrSkipPlugin.Error()) {
91+
pluginErr := fmt.Errorf("failed to load %s.%s: %s", p.Type, p.ID, p.InitErr.Message)
92+
loadErr = errors.Join(loadErr, pluginErr)
93+
}
94+
}
95+
if loadErr != nil {
96+
return nil, loadErr
97+
}
98+
8299
return client, err
83100
case <-ctx.Done():
84101
return nil, fmt.Errorf("context deadline exceeded: %w", err)

0 commit comments

Comments
 (0)