cockpit-podman icon indicating copy to clipboard operation
cockpit-podman copied to clipboard

Health check start period is ignored

Open deadmeu opened this issue 1 year ago • 5 comments
trafficstars

Cockpit version: 311-1~bpo12+1 Cockpit-podman version: 86-1~bpo12+1 Podman version: 4.3.1 OS: Debian 12 (Raspberry Pi OS Lite)

When creating a new container, the start period value in the health check tab seems to be ignored. Regardless of the value populated, as soon as the container is started a health check is performed (and shows as unhealthy for me, at least for the first few seconds).

Steps to reproduce

  1. Open the "Create container" dialog
  2. In the "Health check" tab, set the "Start period" value to 30
  3. Select "Create and run" to create and start the container
  4. Observe a health check on the container running immediately

deadmeu avatar Apr 25 '24 06:04 deadmeu

By any chance do you have podman inspect output of this container?

jelly avatar Sep 05 '24 09:09 jelly

Yes this should be it: podman-inspect-output.json

deadmeu avatar Sep 12 '24 12:09 deadmeu

@deadmeu in the file you sent I can't see StartPeriod option set. Can you please confirm that you set this option when creating the image? The relevant part of inspect should look like something like this:

"Healthcheck": {
                    "Test": [
                         "CMD-SHELL",
                         "dig +short +norecurse +retry=0 @127.0.0.1 pi.hole || exit 1"
                    ],
                    "StartPeriod": 30000000000,
                    "Interval": 30000000000,
                    "Timeout": 30000000000
               },

Regardless of the value populated, as soon as the container is started a health check is performed

According to podman-run docs:

Note: The health check command is executed as soon as a container is started, if the health check is successful the container’s health state will be updated to healthy. However, if the health check fails, the health state will stay as starting until either the health check is successful or until the --health-start-period time is over. If the health check command fails after the --health-start-period time is over, the health state will be updated to unhealthy. The health check command is executed periodically based on the value of --health-interval.

So yes. Regarldes of if you set or don't set StartPeriod the healthcheck will run immediately. However if you set this option the container will show health label "Cheking health" (or status "starting" when using podman ps in cli) until the StartPeriod duration is over.

tomasmatus avatar Sep 16 '24 12:09 tomasmatus

I've just tried it again by following my reported reproduction steps with a new container and setting the Start period value to 30, and the output of sudo podman inspect <container_name> does not include a StartPeriod value. So it looks like it's not setting the value correctly when the container is created from the GUI.

deadmeu avatar Sep 16 '24 12:09 deadmeu

Ok, I am able to reproduce this. For now as a workaround you can manually input the dig command in the health check command in cockpit UI. Then it should work as expected.

tomasmatus avatar Sep 25 '24 14:09 tomasmatus

I'm unable to reproduce this, my podman inspect shows the healthcheck start period. This might have been fixed?

ashley-cui avatar Nov 25 '24 19:11 ashley-cui

As it happens, I ran into this as well. This is just how podman behaves: https://github.com/containers/podman/issues/19272 . By and large, "health check start period" is ignored.

martinpitt avatar Nov 26 '24 06:11 martinpitt