osmith has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38592?usp=email )


Change subject: testenv: make podman stop more robust
......................................................................

testenv: make podman stop more robust

Terminate the watchdog process before killing the podman container. This
avoids bogus errors from a race condition where the container gets
killed first, and then the watchdog process tries to feed the watchdog
and fails:

  [testenv] Stopping podman container
  [testenv] + ['podman', 'kill', 
'testenv-hnbgw-all-osmocom-latest-20241031-1222-f34534a5-1']
  e41700779a8ca5daf18ac5daa27d59a84d8442196e352f2756a19baf0592cf89
  Error: no container with name or ID 
testenv-hnbgw-all-osmocom-latest-20241031-1222-f34534a5-1 found: no such 
container
  [testenv] podman container crashed!

While at it, use "check=False" with the "podman kill" command, so we
avoid additional error messages if the container was already killed at
that point (could happen through a bug). If we fail to kill it here, it
is not a problem because the watchdog will ensure it terminates shortly
after the watchdog process was stopped.

Related: OS#6607
Change-Id: I6c67273af5b6a80ae0c94e14cb92e3784807c21d
---
M _testenv/testenv/podman.py
1 file changed, 5 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/92/38592/1

diff --git a/_testenv/testenv/podman.py b/_testenv/testenv/podman.py
index f849408..538ec41 100644
--- a/_testenv/testenv/podman.py
+++ b/_testenv/testenv/podman.py
@@ -311,6 +311,7 @@
     global container_name
     global run_shell_on_stop
     global restart_count
+    global feed_watchdog_process

     if not is_running():
         return
@@ -329,10 +330,13 @@

     restart_msg = " (restart)" if restart else ""
     logging.info(f"Stopping podman container{restart_msg}")
-    testenv.cmd.run(["podman", "kill", container_name], no_podman=True)

     if feed_watchdog_process:
         feed_watchdog_process.terminate()
+        feed_watchdog_process.wait()
+        feed_watchdog_process = None
+
+    testenv.cmd.run(["podman", "kill", container_name], no_podman=True, 
check=False)

     if restart:
         testenv.cmd.run(["podman", "wait", container_name], no_podman=True, 
check=False)

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/38592?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I6c67273af5b6a80ae0c94e14cb92e3784807c21d
Gerrit-Change-Number: 38592
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <[email protected]>

Reply via email to