Skip to content

Commit b1a23c4

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]>
1 parent d4148d9 commit b1a23c4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

integration/client/daemon.go

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

31+
"github.com/containerd/plugin"
32+
3033
. "github.com/containerd/containerd/v2/client"
3134
)
3235

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

0 commit comments

Comments
 (0)