@@ -50,7 +50,10 @@ var _ = Describe("Podman run device", func() {
5050 Expect (session ).Should (ExitCleanly ())
5151 if ! isRootless () {
5252 // 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" })
5457 session .WaitWithDefaultTimeout ()
5558 Expect (session ).Should (ExitCleanly ())
5659 }
@@ -152,9 +155,12 @@ var _ = Describe("Podman run device", func() {
152155 })
153156
154157 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" })
156162 session .WaitWithDefaultTimeout ()
157- Expect (session ).Should ( Not ( ExitCleanly () ))
163+ Expect (session ).To ( ExitWithErrorRegex ( 1 , "head: /dev-host/kmsg: (Operation not permitted|Permission denied)" ))
158164 })
159165
160166})
0 commit comments