Skip to content

Commit

Permalink
integration/TraceOOMKill: Don't check fuid and fgid
Browse files Browse the repository at this point in the history
It can't be assured that our `tail` process will trigger the oomkill. It
could be another process with another uid and gid

Fixes: efd6f97
Signed-off-by: Burak Ok <[email protected]>
  • Loading branch information
burak-ok committed Jan 26, 2024
1 parent 7392ec3 commit 249101e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
8 changes: 4 additions & 4 deletions integration/ig/k8s/trace_oomkill_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ func TestTraceOOMKill(t *testing.T) {
WithRuntimeMetadata(*containerRuntime),
WithContainerImageName("docker.io/library/busybox:latest", isDockerRuntime),
),
KilledComm: "tail",
TriggeredUid: 1000,
TriggeredGid: 2000,
KilledComm: "tail",
}

normalize := func(e *oomkillTypes.Event) {
Expand All @@ -57,6 +55,8 @@ func TestTraceOOMKill(t *testing.T) {
e.KilledPid = 0
e.Pages = 0
e.TriggeredPid = 0
e.TriggeredUid = 0
e.TriggeredGid = 0
e.TriggeredComm = ""
e.MountNsID = 0

Expand Down Expand Up @@ -90,7 +90,7 @@ spec:
memory: "128Mi"
command: ["/bin/sh", "-c"]
args:
- setuidgid 1000:2000 sh -c "while true; do tail /dev/zero; done"
- while true; do tail /dev/zero; done
`, ns)

commands := []*Command{
Expand Down
11 changes: 7 additions & 4 deletions integration/inspektor-gadget/run_trace_oomkill_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ func runTraceOOMKill(t *testing.T, ns string, cmd string) {

expectedTraceOOMKillJsonObj := map[string]interface{}{
"fpid": 0,
"fuid": 1000,
"fgid": 2000,
"fuid": 0,
"fgid": 0,
"tpid": 0,
"pages": 0,
"mntns_id": 0,
"timestamp": "",
"fcomm": "tail",
"fcomm": "",
"tcomm": "tail",
}

Expand All @@ -58,7 +58,10 @@ func runTraceOOMKill(t *testing.T, ns string, cmd string) {
SetEventRuntimeContainerID(m, "")
SetEventRuntimeContainerName(m, "")

m["fcomm"] = ""
m["fpid"] = uint32(0)
m["fuid"] = uint32(0)
m["fgid"] = uint32(0)
m["tpid"] = uint32(0)
m["pages"] = uint32(0)
m["mntns_id"] = 0
Expand Down Expand Up @@ -86,7 +89,7 @@ spec:
memory: "128Mi"
command: ["/bin/sh", "-c"]
args:
- setuidgid 1000:2000 sh -c "while true; do tail /dev/zero; done"
- while true; do tail /dev/zero; done
`, ns)

commands := []*Command{
Expand Down
10 changes: 5 additions & 5 deletions integration/inspektor-gadget/trace_oomkill_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ func TestTraceOOMKill(t *testing.T) {
StartAndStop: true,
ValidateOutput: func(t *testing.T, output string) {
expectedEntry := &traceoomkillTypes.Event{
Event: BuildBaseEvent(ns, WithContainerImageName("docker.io/library/busybox:latest", isDockerRuntime)),
KilledComm: "tail",
TriggeredUid: 1000,
TriggeredGid: 2000,
Event: BuildBaseEvent(ns, WithContainerImageName("docker.io/library/busybox:latest", isDockerRuntime)),
KilledComm: "tail",
}
expectedEntry.K8s.ContainerName = "test-pod-container"

Expand All @@ -49,6 +47,8 @@ func TestTraceOOMKill(t *testing.T) {
e.KilledPid = 0
e.Pages = 0
e.TriggeredPid = 0
e.TriggeredUid = 0
e.TriggeredGid = 0
e.TriggeredComm = ""
e.MountNsID = 0

Expand Down Expand Up @@ -81,7 +81,7 @@ spec:
memory: "128Mi"
command: ["/bin/sh", "-c"]
args:
- setuidgid 1000:2000 sh -c "while true; do tail /dev/zero; done"
- while true; do tail /dev/zero; done
`, ns)

commands := []*Command{
Expand Down

0 comments on commit 249101e

Please sign in to comment.