Skip to content

Commit 6adbc2e

Browse files
committed
cdi: use oci.WithCDIDevices since containerd v2
Signed-off-by: CrazyMax <[email protected]>
1 parent d4a0f7e commit 6adbc2e

File tree

1 file changed

+1
-24
lines changed

1 file changed

+1
-24
lines changed

executor/oci/spec_linux.go

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/containerd/containerd/v2/pkg/oci"
1515
cdseccomp "github.com/containerd/containerd/v2/pkg/seccomp"
1616
"github.com/containerd/continuity/fs"
17-
"github.com/containerd/log"
1817
"github.com/docker/docker/pkg/idtools"
1918
"github.com/docker/docker/profiles/seccomp"
2019
"github.com/moby/buildkit/snapshot"
@@ -191,31 +190,9 @@ func generateCDIOpts(ctx context.Context, devices []*pb.CDIDevice) ([]oci.SpecOp
191190
}
192191
}
193192

194-
// withCDIDevices injects the requested CDI devices into the OCI specification.
195-
// FIXME: Use oci.WithCDIDevices once we switch to containerd 2.0.
196-
withCDIDevices := func(devices ...string) oci.SpecOpts {
197-
return func(ctx context.Context, _ oci.Client, c *containers.Container, s *specs.Spec) error {
198-
if len(devices) == 0 {
199-
return nil
200-
}
201-
if err := cdi.Refresh(); err != nil {
202-
log.G(ctx).Warnf("CDI registry refresh failed: %v", err)
203-
}
204-
bklog.G(ctx).Debugf("Injecting CDI devices %v", devices)
205-
if _, err := cdi.InjectDevices(s, devices...); err != nil {
206-
return errors.Wrapf(err, "CDI device injection failed")
207-
}
208-
// One crucial thing to keep in mind is that CDI device injection
209-
// might add OCI Spec environment variables, hooks, and mounts as
210-
// well. Therefore, it is important that none of the corresponding
211-
// OCI Spec fields are reset up in the call stack once we return.
212-
return nil
213-
}
214-
}
215-
216193
return []oci.SpecOpts{
217194
withStaticCDIRegistry(),
218-
withCDIDevices(dd...),
195+
oci.WithCDIDevices(dd...),
219196
}, nil
220197
}
221198

0 commit comments

Comments
 (0)