Skip to content

Commit bc6d313

Browse files
laurall974Laura Llinares
andauthored
fix(kubernetes): make kubepods pattern compatible with qos guaranteed pods (#2357)
Signed-off-by: Laura Llinares <[email protected]> Co-authored-by: Laura Llinares <[email protected]>
1 parent 9b9761e commit bc6d313

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

internal/resource/container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var (
2121
libpodPattern = regexp.MustCompile(`libpod-([0-9a-f]{64}).*`)
2222
libpodPayloadPattern = regexp.MustCompile(`/libpod-payload-([0-9a-f]+)`)
2323

24-
kubepodsPattern = regexp.MustCompile(`/kubepods/[^/]+/pod[0-9a-f\-]+/([0-9a-f]{64})`)
24+
kubepodsPattern = regexp.MustCompile(`/kubepods/(?:[^/]+/)?pod[0-9a-f\-]+/([0-9a-f]{64})`)
2525
)
2626

2727
// containerPatterns maps pre-compiled patterns to runtime types

internal/resource/container_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@ func TestContainerIDFromPathWithCgroup(t *testing.T) {
128128
path: "11:blkio:/kubepods/burstable/podf6adb0af-0855-4bab-b25b-c853f18d0ce2/35b97177dada20362ab90d90ac63cd54e8a41cf87bea34f270631b6da17f4a93",
129129

130130
expected: expect{id: "35b97177dada20362ab90d90ac63cd54e8a41cf87bea34f270631b6da17f4a93", runtime: KubePodsRuntime},
131+
}, {
132+
name: "valid path with guaranteed qos pod",
133+
path: "0::/kubepods/pod51b64565-2b17-4d46-83ac-22e398f2f7fb/65d752a38e1db784d521f48c3f1956f4f9a74ebb923377144f253f3aca9fa028",
134+
135+
expected: expect{id: "65d752a38e1db784d521f48c3f1956f4f9a74ebb923377144f253f3aca9fa028", runtime: KubePodsRuntime},
136+
}, {
137+
name: "valid path with burstable qos pod",
138+
path: "0::/kubepods/burstable/pod5a89bcaa-3509-4375-83e1-b9e7a5712123/a069581483b00a498b3ba172612ffed06b3275a043bf3895c1b19e783e2793ee",
139+
140+
expected: expect{id: "a069581483b00a498b3ba172612ffed06b3275a043bf3895c1b19e783e2793ee", runtime: KubePodsRuntime},
131141
}, {
132142
name: "podman rootless container",
133143
path: "0::/user.slice/user-1000.slice/[email protected]/user.slice/libpod-3f05ee050f82c0145f1d88c94269c39dff0f07dbf8bba20aafd54b3a75dcaecc.scope/container",

0 commit comments

Comments
 (0)