diff options
author | openshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com> | 2022-06-27 17:49:27 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-27 17:49:27 +0000 |
commit | 278afae1de55a2951b2a4810b100d14e5647977b (patch) | |
tree | 127c92338c22c1763c4564d43ba1c6eed34ac9c5 /libpod/healthcheck.go | |
parent | ed2afb2059744defccd40894b5f23e3803f6b3c5 (diff) | |
parent | 0c1a3b70f5f1b8a3f8d336c6576518fae26c37cf (diff) | |
download | podman-278afae1de55a2951b2a4810b100d14e5647977b.tar.gz podman-278afae1de55a2951b2a4810b100d14e5647977b.tar.bz2 podman-278afae1de55a2951b2a4810b100d14e5647977b.zip |
Merge pull request #14705 from jakecorrenti/show-health-status-event
Show Health Status events
Diffstat (limited to 'libpod/healthcheck.go')
-rw-r--r-- | libpod/healthcheck.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libpod/healthcheck.go b/libpod/healthcheck.go index bd77e98c6..95c70b60e 100644 --- a/libpod/healthcheck.go +++ b/libpod/healthcheck.go @@ -90,7 +90,7 @@ func (c *Container) runHealthCheck() (define.HealthCheckStatus, error) { hcResult := define.HealthCheckSuccess config := new(ExecConfig) config.Command = newCommand - exitCode, hcErr := c.Exec(config, streams, nil) + exitCode, hcErr := c.exec(config, streams, nil, true) if hcErr != nil { errCause := errors.Cause(hcErr) hcResult = define.HealthCheckFailure @@ -232,18 +232,27 @@ func (c *Container) getHealthCheckLog() (define.HealthCheckResults, error) { // HealthCheckStatus returns the current state of a container with a healthcheck func (c *Container) HealthCheckStatus() (string, error) { + c.lock.Lock() + defer c.lock.Unlock() + return c.healthCheckStatus() +} + +// Internal function to return the current state of a container with a healthcheck. +// This function does not lock the container. +func (c *Container) healthCheckStatus() (string, error) { if !c.HasHealthCheck() { return "", errors.Errorf("container %s has no defined healthcheck", c.ID()) } - c.lock.Lock() - defer c.lock.Unlock() + if err := c.syncContainer(); err != nil { return "", err } + results, err := c.getHealthCheckLog() if err != nil { return "", errors.Wrapf(err, "unable to get healthcheck log for %s", c.ID()) } + return results.Status, nil } |