Bug 2180126

Summary: --health-on-failure=restart doesn't restart container [rhel-9.2.0.z]
Product: Red Hat Enterprise Linux 9 Reporter: RHEL Program Management Team <pgm-rhel-tools>
Component: podmanAssignee: Jindrich Novy <jnovy>
Status: CLOSED ERRATA QA Contact: Alex Jia <ajia>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 9.3CC: acui, bbaude, container-sig, debarshir, dwalsh, extras-qa, gary.revell, go-sig, jnovy, kpfleming, lsm5, mboddu, mheon, patrick, pehunt, pthomas, rh.container.bot, santiago, tsweeney, umohnani, vrothber, ypu
Target Milestone: rcKeywords: Triaged, ZStream
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: podman-4.4.1-5.el9_2 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 2180108 Environment:
Last Closed: 2023-05-09 11:02:52 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2180108    
Bug Blocks:    

Comment 1 Tom Sweeney 2023-03-20 19:07:37 UTC
Valentin, please use this BZ and https://bugzilla.redhat.com/show_bug.cgi?id=2180125 to merge into the Podman v4.4.1-rhel branch when your patch there is ready.

Comment 2 Valentin Rothberg 2023-03-21 08:21:47 UTC
Opened PR: https://github.com/containers/podman/pull/17863

Comment 3 Valentin Rothberg 2023-03-21 11:54:08 UTC
PR has merged, assigning to Jindrich.

Comment 6 Alex Jia 2023-03-23 09:36:38 UTC
This bug has been verified on podman-4.4.1-5.el9_2.

[root@kvm-01-guest10 ~]# sh -x test.sh 
+ IMG=ubi8
+ podman ps -a
CONTAINER ID  IMAGE                                   COMMAND     CREATED         STATUS                    PORTS       NAMES
329a5332b8ca  registry.access.redhat.com/ubi8:latest  sleep 300   10 minutes ago  Exited (0) 4 minutes ago              frosty_sammet
+ podman run --replace -d --name true_container --health-cmd true --health-on-failure=restart --health-interval 15s --health-retries=2 ubi8 sleep 300
50a6aa7f921dff6b823dc39e571d80d4548960f82658574c8066f8215155a2a0
+ podman run --replace -d --name false_container --health-cmd false --health-on-failure=restart --health-interval 15s --health-retries=2 ubi8 sleep 300
0699bad073c3006fed5b1fd2a353a96d8d19ca6e214deffd6463020946c2b07a
++ date +%H:%M:%S
+ echo 05:01:43 Created false_container
05:01:43 Created false_container
+ true
+ sleep 5
+ date +%H:%M:%S
05:01:48
+ podman ps -a
CONTAINER ID  IMAGE                                   COMMAND     CREATED         STATUS                    PORTS       NAMES
329a5332b8ca  registry.access.redhat.com/ubi8:latest  sleep 300   10 minutes ago  Exited (0) 5 minutes ago              frosty_sammet
50a6aa7f921d  registry.access.redhat.com/ubi8:latest  sleep 300   5 seconds ago   Up 5 seconds (healthy)                true_container
0699bad073c3  registry.access.redhat.com/ubi8:latest  sleep 300   5 seconds ago   Up 5 seconds (starting)               false_container
+ true
+ sleep 5
+ date +%H:%M:%S
05:01:53
+ podman ps -a
CONTAINER ID  IMAGE                                   COMMAND     CREATED         STATUS                    PORTS       NAMES
329a5332b8ca  registry.access.redhat.com/ubi8:latest  sleep 300   10 minutes ago  Exited (0) 5 minutes ago              frosty_sammet
50a6aa7f921d  registry.access.redhat.com/ubi8:latest  sleep 300   10 seconds ago  Up 10 seconds (healthy)               true_container
0699bad073c3  registry.access.redhat.com/ubi8:latest  sleep 300   10 seconds ago  Up 10 seconds (starting)              false_container
+ true
+ sleep 5
+ date +%H:%M:%S
05:01:58
+ podman ps -a
CONTAINER ID  IMAGE                                   COMMAND     CREATED         STATUS                    PORTS       NAMES
329a5332b8ca  registry.access.redhat.com/ubi8:latest  sleep 300   10 minutes ago  Exited (0) 5 minutes ago              frosty_sammet
50a6aa7f921d  registry.access.redhat.com/ubi8:latest  sleep 300   15 seconds ago  Up 15 seconds (healthy)               true_container
0699bad073c3  registry.access.redhat.com/ubi8:latest  sleep 300   15 seconds ago  Up 15 seconds (starting)              false_container
+ true
+ sleep 5
+ date +%H:%M:%S
05:02:03
+ podman ps -a
CONTAINER ID  IMAGE                                   COMMAND     CREATED         STATUS                    PORTS       NAMES
329a5332b8ca  registry.access.redhat.com/ubi8:latest  sleep 300   10 minutes ago  Exited (0) 5 minutes ago              frosty_sammet
50a6aa7f921d  registry.access.redhat.com/ubi8:latest  sleep 300   20 seconds ago  Up 20 seconds (healthy)               true_container
0699bad073c3  registry.access.redhat.com/ubi8:latest  sleep 300   20 seconds ago  Stopping (unhealthy)                  false_container
+ true
+ sleep 5
+ date +%H:%M:%S
05:02:08
+ podman ps -a
CONTAINER ID  IMAGE                                   COMMAND     CREATED         STATUS                    PORTS       NAMES
329a5332b8ca  registry.access.redhat.com/ubi8:latest  sleep 300   10 minutes ago  Exited (0) 5 minutes ago              frosty_sammet
50a6aa7f921d  registry.access.redhat.com/ubi8:latest  sleep 300   25 seconds ago  Up 25 seconds (healthy)               true_container
0699bad073c3  registry.access.redhat.com/ubi8:latest  sleep 300   25 seconds ago  Stopping (unhealthy)                  false_container
+ true
+ sleep 5
+ date +%H:%M:%S
05:02:13
+ podman ps -a
CONTAINER ID  IMAGE                                   COMMAND     CREATED         STATUS                    PORTS       NAMES
329a5332b8ca  registry.access.redhat.com/ubi8:latest  sleep 300   11 minutes ago  Exited (0) 5 minutes ago              frosty_sammet
50a6aa7f921d  registry.access.redhat.com/ubi8:latest  sleep 300   30 seconds ago  Up 30 seconds (healthy)               true_container
0699bad073c3  registry.access.redhat.com/ubi8:latest  sleep 300   30 seconds ago  Up 4 seconds (starting)               false_container
...ignore...

Comment 19 errata-xmlrpc 2023-05-09 11:02:52 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (podman bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2620