Skip to content

Commit 706a814

Browse files
committed
Avoid platforms.Default by passing arch down earlier
1 parent d88bd1b commit 706a814

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cmd/bashbrew/containerd.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"github.com/containerd/containerd/content/local"
1111
"github.com/containerd/containerd/metadata"
1212
"github.com/containerd/containerd/namespaces"
13+
"github.com/containerd/containerd/platforms"
14+
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
1315

1416
"go.etcd.io/bbolt"
1517
)
@@ -61,6 +63,11 @@ func newContainerdClient(ctx context.Context) (context.Context, *containerd.Clie
6163
return ctx, containerdClientCache, nil
6264
}
6365

66+
opts := []containerd.ClientOpt{
67+
// we want to avoid "platforms.Default()" from trying to do detection (and sometimes erroring about "getCPUInfo" not having a variant), so we'll pass an explicit platform matcher
68+
containerd.WithDefaultPlatform(platforms.OnlyStrict(ocispec.Platform(ociArch))),
69+
}
70+
6471
for _, envKey := range []string{
6572
`BASHBREW_CONTAINERD_CONTENT_ADDRESS`, // TODO if we ever need to connnect to a containerd instance for something more interesting like running containers, we need to have *that* codepath not use _CONTENT_ variants
6673
`BASHBREW_CONTAINERD_ADDRESS`,
@@ -72,7 +79,7 @@ func newContainerdClient(ctx context.Context) (context.Context, *containerd.Clie
7279
// we'll use a set-but-empty variable as an explicit request to use our built-in implementation
7380
break
7481
}
75-
client, err := containerd.New(socket)
82+
client, err := containerd.New(socket, opts...)
7683
containerdClientCache = client
7784
return ctx, client, err
7885
}
@@ -83,7 +90,9 @@ func newContainerdClient(ctx context.Context) (context.Context, *containerd.Clie
8390
if err != nil {
8491
return ctx, nil, err
8592
}
86-
client, err := containerd.New("", services)
93+
opts = append(opts, services)
94+
95+
client, err := containerd.New("", opts...)
8796
containerdClientCache = client
8897
return ctx, client, err
8998
}

0 commit comments

Comments
 (0)