@@ -416,18 +416,34 @@ func TestReadCIDOrInode(t *testing.T) {
416
416
isHostCgroupNs : true ,
417
417
expectedResult : "8c046cb0b72cd4c99f51b5591cd5b095967f58ee003710a45280c28ee1a9c7fa" , // Will be formatted with inode number
418
418
},
419
-
419
+ {
420
+ description : "extract container-id from /proc/self/cgroup in private cgroup ns" ,
421
+ procSelfCgroupContent : "4:blkio:/kubepods/burstable/podfd52ef25-a87d-11e9-9423-0800271a638e/8c046cb0b72cd4c99f51b5591cd5b095967f58ee003710a45280c28ee1a9c7fa\n " ,
422
+ expectedResult : "8c046cb0b72cd4c99f51b5591cd5b095967f58ee003710a45280c28ee1a9c7fa" , // Will be formatted with inode number
423
+ },
424
+ {
425
+ description : "extract container-id from mountinfo in private cgroup ns" ,
426
+ mountInfoContent : "2282 2269 8:1 /var/lib/containerd/io.containerd.grpc.v1.cri/sandboxes/c0a82a3506b0366c9666f6dbe71c783abeb26ba65e312e918a49e10a277196d0/hostname /host/var/run/containerd/io.containerd.runtime.v2.task/k8s.io/fc7038bc73a8d3850c66ddbfb0b2901afa378bfcbb942cc384b051767e4ac6b0/rootfs/etc/hostname rw,nosuid,nodev,relatime - ext4 /dev/sda1 rw,commit=30\n " ,
427
+ expectedResult : "fc7038bc73a8d3850c66ddbfb0b2901afa378bfcbb942cc384b051767e4ac6b0" ,
428
+ },
420
429
{
421
430
description : "extract container-id from mountinfo" ,
422
431
mountInfoContent : "2282 2269 8:1 /var/lib/containerd/io.containerd.grpc.v1.cri/sandboxes/c0a82a3506b0366c9666f6dbe71c783abeb26ba65e312e918a49e10a277196d0/hostname /host/var/run/containerd/io.containerd.runtime.v2.task/k8s.io/fc7038bc73a8d3850c66ddbfb0b2901afa378bfcbb942cc384b051767e4ac6b0/rootfs/etc/hostname rw,nosuid,nodev,relatime - ext4 /dev/sda1 rw,commit=30\n " ,
423
432
expectedResult : "fc7038bc73a8d3850c66ddbfb0b2901afa378bfcbb942cc384b051767e4ac6b0" ,
433
+ isHostCgroupNs : true ,
424
434
},
425
435
{
426
- description : "extract inode" ,
436
+ description : "extract inode only in private cgroup ns " ,
427
437
cgroupNodeDir : "system.slice/docker-abcdef0123456789abcdef0123456789.scope" ,
428
438
procSelfCgroupContent : "0::/system.slice/docker-abcdef0123456789abcdef0123456789.scope\n " ,
429
439
expectedResult : "in-%d" ,
430
440
},
441
+ {
442
+ description : "do not extract inode in host cgroup ns" ,
443
+ cgroupNodeDir : "system.slice/docker-abcdef0123456789abcdef0123456789.scope" ,
444
+ procSelfCgroupContent : "0::/system.slice/docker-abcdef0123456789abcdef0123456789.scope\n " ,
445
+ isHostCgroupNs : true ,
446
+ },
431
447
}
432
448
433
449
for _ , tc := range tests {
0 commit comments