@@ -50,7 +50,10 @@ var _ = Describe("Podman run device", func() {
50
50
Expect (session ).Should (ExitCleanly ())
51
51
if ! isRootless () {
52
52
// Kernel 6.9.0 (2024-03) requires SYSLOG
53
- session = podmanTest .Podman ([]string {"run" , "-q" , "--security-opt" , "label=disable" , "--device" , "/dev/kmsg" , "--cap-add" , "SYS_ADMIN,SYSLOG" , ALPINE , "head" , "-n" , "1" , "/dev/kmsg" })
53
+ // Do not read any data from the device (thus the -n 0), because there is a rare race condition that happens
54
+ // when another writes to the ring buffer when the device is already opened and that causes the following test
55
+ // to fail: https://github.com/containers/podman/issues/23882.
56
+ session = podmanTest .Podman ([]string {"run" , "-q" , "--security-opt" , "label=disable" , "--device" , "/dev/kmsg" , "--cap-add" , "SYS_ADMIN,SYSLOG" , ALPINE , "head" , "-n" , "0" , "/dev/kmsg" })
54
57
session .WaitWithDefaultTimeout ()
55
58
Expect (session ).Should (ExitCleanly ())
56
59
}
@@ -152,9 +155,12 @@ var _ = Describe("Podman run device", func() {
152
155
})
153
156
154
157
It ("podman run cannot access non default devices" , func () {
155
- session := podmanTest .Podman ([]string {"run" , "-v /dev:/dev-host" , ALPINE , "head" , "-1" , "/dev-host/kmsg" })
158
+ // Unlikely to happen but do not read any data from the device (thus the -n 0), because there is a rare
159
+ // race condition that happens so the test would fail for the rare race condition instead of a failure
160
+ // reported by open(). More details: https://github.com/containers/podman/issues/23882.
161
+ session := podmanTest .Podman ([]string {"run" , "-v" , "/dev:/dev-host" , ALPINE , "head" , "-n0" , "/dev-host/kmsg" })
156
162
session .WaitWithDefaultTimeout ()
157
- Expect (session ).Should ( Not ( ExitCleanly () ))
163
+ Expect (session ).To ( ExitWithErrorRegex ( 1 , "head: /dev-host/kmsg: (Operation not permitted|Permission denied)" ))
158
164
})
159
165
160
166
})
0 commit comments