@@ -38,7 +38,7 @@ const (
38
38
)
39
39
40
40
// NewContainerd creates a new containerd adapter
41
- func NewContainerd (cfg * ContainerdConfig , mounts * NodeMountsLookup , pathMapping PathMapping ) (* Containerd , error ) {
41
+ func NewContainerd (cfg * ContainerdConfig , pathMapping PathMapping ) (* Containerd , error ) {
42
42
cc , err := containerd .New (cfg .SocketPath , containerd .WithDefaultNamespace (kubernetesNamespace ))
43
43
if err != nil {
44
44
return nil , xerrors .Errorf ("cannot connect to containerd at %s: %w" , cfg .SocketPath , err )
@@ -52,7 +52,6 @@ func NewContainerd(cfg *ContainerdConfig, mounts *NodeMountsLookup, pathMapping
52
52
53
53
res := & Containerd {
54
54
Client : cc ,
55
- Mounts : mounts ,
56
55
Mapping : pathMapping ,
57
56
58
57
cond : sync .NewCond (& sync.Mutex {}),
@@ -68,7 +67,6 @@ func NewContainerd(cfg *ContainerdConfig, mounts *NodeMountsLookup, pathMapping
68
67
// Containerd implements the ws-daemon CRI for containerd
69
68
type Containerd struct {
70
69
Client * containerd.Client
71
- Mounts * NodeMountsLookup
72
70
Mapping PathMapping
73
71
74
72
cond * sync.Cond
@@ -440,27 +438,18 @@ func (s *Containerd) ContainerExists(ctx context.Context, id ID) (exists bool, e
440
438
441
439
// ContainerRootfs finds the workspace container's rootfs.
442
440
func (s * Containerd ) ContainerRootfs (ctx context.Context , id ID , opts OptsContainerRootfs ) (loc string , err error ) {
443
- info , ok := s .cntIdx [string (id )]
441
+ _ , ok := s .cntIdx [string (id )]
444
442
if ! ok {
445
443
return "" , ErrNotFound
446
444
}
447
445
448
- // TODO(cw): make this less brittle
449
- // We can't get the rootfs location on the node from containerd somehow.
450
- // As a workaround we'll look at the node's mount table using the snapshotter key.
451
- // This feels brittle and we should keep looking for a better way.
452
- mnt , err := s .Mounts .GetMountpoint (func (mountPoint string ) bool {
453
- return strings .Contains (mountPoint , info .SnapshotKey )
454
- })
455
- if err != nil {
456
- return
457
- }
446
+ rootfs := fmt .Sprintf ("/run/containerd/io.containerd.runtime.v2.task/k8s.io/%v/rootfs" , id )
458
447
459
448
if opts .Unmapped {
460
- return mnt , nil
449
+ return rootfs , nil
461
450
}
462
451
463
- return s .Mapping .Translate (mnt )
452
+ return s .Mapping .Translate (rootfs )
464
453
}
465
454
466
455
// ContainerCGroupPath finds the container's cgroup path suffix
0 commit comments