From b9aa4755559d50d39bee3f571734a1e17c0f08b2 Mon Sep 17 00:00:00 2001
From: Valentin Rothberg <vrothberg@redhat.com>
Date: Tue, 5 Jul 2022 12:18:27 +0200
Subject: Sync: handle exit file

Make sure `Sync()` handles state transitions and exit codes correctly.
The function was only being called when batching which could render
containers in an unusable state when running concurrently with other
state-altering functions/commands since the state must be re-read from
the database before acting upon it.

Fixes: #14761
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
---
 test/system/130-kill.bats | 10 ++++++++++
 1 file changed, 10 insertions(+)

(limited to 'test')

diff --git a/test/system/130-kill.bats b/test/system/130-kill.bats
index a9456e03c..96b633a42 100644
--- a/test/system/130-kill.bats
+++ b/test/system/130-kill.bats
@@ -130,4 +130,14 @@ load helpers
     is "$output" $cname
 }
 
+@test "podman kill - concurrent stop" {
+    # 14761 - concurrent kill/stop must record the exit code
+    random_name=$(random_string 10)
+    run_podman run -d --replace --name=$random_name alpine sh -c "trap 'echo Received SIGTERM, ignoring' SIGTERM; echo READY; while :; do sleep 0.2; done"
+    $PODMAN stop -t 1 $random_name &
+    run_podman kill $random_name
+    run_podman wait $random_name
+    run_podman rm -f $random_name
+}
+
 # vim: filetype=sh
-- 
cgit v1.2.3-54-g00ecf