mirror of
https://github.com/containers/podman.git
synced 2025-06-23 18:59:30 +08:00
Stop outputting 'healthy' on healthcheck
We should only print unhealthy if the check fails. Currently this is filling logs when users are running lots of healthchecks. Improves: https://github.com/containers/podman/issues/11157 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/containers/podman/v3/cmd/podman/common"
|
"github.com/containers/podman/v3/cmd/podman/common"
|
||||||
"github.com/containers/podman/v3/cmd/podman/registry"
|
"github.com/containers/podman/v3/cmd/podman/registry"
|
||||||
|
"github.com/containers/podman/v3/libpod/define"
|
||||||
"github.com/containers/podman/v3/pkg/domain/entities"
|
"github.com/containers/podman/v3/pkg/domain/entities"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -34,9 +35,9 @@ func run(cmd *cobra.Command, args []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if response.Status == "unhealthy" {
|
if response.Status == define.HealthCheckUnhealthy {
|
||||||
registry.SetExitCode(1)
|
registry.SetExitCode(1)
|
||||||
|
fmt.Println(response.Status)
|
||||||
}
|
}
|
||||||
fmt.Println(response.Status)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -326,11 +326,11 @@ var _ = Describe("Podman containers ", func() {
|
|||||||
// TODO for the life of me, i cannot get this to work. maybe another set
|
// TODO for the life of me, i cannot get this to work. maybe another set
|
||||||
// of eyes will
|
// of eyes will
|
||||||
// successful healthcheck
|
// successful healthcheck
|
||||||
//status := "healthy"
|
//status := define.HealthCheckHealthy
|
||||||
//for i:=0; i < 10; i++ {
|
//for i:=0; i < 10; i++ {
|
||||||
// result, err := containers.RunHealthCheck(connText, "hc")
|
// result, err := containers.RunHealthCheck(connText, "hc")
|
||||||
// Expect(err).To(BeNil())
|
// Expect(err).To(BeNil())
|
||||||
// if result.Status != "healthy" {
|
// if result.Status != define.HealthCheckHealthy {
|
||||||
// fmt.Println("Healthcheck container still starting, retrying in 1 second")
|
// fmt.Println("Healthcheck container still starting, retrying in 1 second")
|
||||||
// time.Sleep(1 * time.Second)
|
// time.Sleep(1 * time.Second)
|
||||||
// continue
|
// continue
|
||||||
@ -338,7 +338,7 @@ var _ = Describe("Podman containers ", func() {
|
|||||||
// status = result.Status
|
// status = result.Status
|
||||||
// break
|
// break
|
||||||
//}
|
//}
|
||||||
//Expect(status).To(Equal("healthy"))
|
//Expect(status).To(Equal(define.HealthCheckHealthy))
|
||||||
|
|
||||||
// TODO enable this when wait is working
|
// TODO enable this when wait is working
|
||||||
// healthcheck on a stopped container should be a 409
|
// healthcheck on a stopped container should be a 409
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
define "github.com/containers/podman/v3/libpod/define"
|
||||||
. "github.com/containers/podman/v3/test/utils"
|
. "github.com/containers/podman/v3/test/utils"
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
@ -157,7 +158,7 @@ var _ = Describe("Podman healthcheck run", func() {
|
|||||||
Expect(hc).Should(Exit(1))
|
Expect(hc).Should(Exit(1))
|
||||||
|
|
||||||
inspect = podmanTest.InspectContainer("hc")
|
inspect = podmanTest.InspectContainer("hc")
|
||||||
Expect(inspect[0].State.Healthcheck.Status).To(Equal("unhealthy"))
|
Expect(inspect[0].State.Healthcheck.Status).To(Equal(define.HealthCheckUnhealthy))
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -171,7 +172,7 @@ var _ = Describe("Podman healthcheck run", func() {
|
|||||||
Expect(hc).Should(Exit(0))
|
Expect(hc).Should(Exit(0))
|
||||||
|
|
||||||
inspect := podmanTest.InspectContainer("hc")
|
inspect := podmanTest.InspectContainer("hc")
|
||||||
Expect(inspect[0].State.Healthcheck.Status).To(Equal("healthy"))
|
Expect(inspect[0].State.Healthcheck.Status).To(Equal(define.HealthCheckHealthy))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman healthcheck unhealthy but valid arguments check", func() {
|
It("podman healthcheck unhealthy but valid arguments check", func() {
|
||||||
@ -201,7 +202,7 @@ var _ = Describe("Podman healthcheck run", func() {
|
|||||||
Expect(hc).Should(Exit(1))
|
Expect(hc).Should(Exit(1))
|
||||||
|
|
||||||
inspect = podmanTest.InspectContainer("hc")
|
inspect = podmanTest.InspectContainer("hc")
|
||||||
Expect(inspect[0].State.Healthcheck.Status).To(Equal("unhealthy"))
|
Expect(inspect[0].State.Healthcheck.Status).To(Equal(define.HealthCheckUnhealthy))
|
||||||
|
|
||||||
foo := podmanTest.Podman([]string{"exec", "hc", "touch", "/foo"})
|
foo := podmanTest.Podman([]string{"exec", "hc", "touch", "/foo"})
|
||||||
foo.WaitWithDefaultTimeout()
|
foo.WaitWithDefaultTimeout()
|
||||||
@ -212,6 +213,6 @@ var _ = Describe("Podman healthcheck run", func() {
|
|||||||
Expect(hc).Should(Exit(0))
|
Expect(hc).Should(Exit(0))
|
||||||
|
|
||||||
inspect = podmanTest.InspectContainer("hc")
|
inspect = podmanTest.InspectContainer("hc")
|
||||||
Expect(inspect[0].State.Healthcheck.Status).To(Equal("healthy"))
|
Expect(inspect[0].State.Healthcheck.Status).To(Equal(define.HealthCheckHealthy))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containers/common/pkg/config"
|
"github.com/containers/common/pkg/config"
|
||||||
|
"github.com/containers/podman/v3/libpod/define"
|
||||||
"github.com/containers/podman/v3/pkg/util"
|
"github.com/containers/podman/v3/pkg/util"
|
||||||
. "github.com/containers/podman/v3/test/utils"
|
. "github.com/containers/podman/v3/test/utils"
|
||||||
"github.com/containers/storage/pkg/stringid"
|
"github.com/containers/storage/pkg/stringid"
|
||||||
@ -1209,7 +1210,7 @@ var _ = Describe("Podman play kube", func() {
|
|||||||
hc := podmanTest.Podman([]string{"healthcheck", "run", "liveness-unhealthy-probe-pod-0-alpine"})
|
hc := podmanTest.Podman([]string{"healthcheck", "run", "liveness-unhealthy-probe-pod-0-alpine"})
|
||||||
hc.WaitWithDefaultTimeout()
|
hc.WaitWithDefaultTimeout()
|
||||||
hcoutput := hc.OutputToString()
|
hcoutput := hc.OutputToString()
|
||||||
Expect(hcoutput).To(ContainSubstring("unhealthy"))
|
Expect(hcoutput).To(ContainSubstring(define.HealthCheckUnhealthy))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman play kube fail with nonexistent authfile", func() {
|
It("podman play kube fail with nonexistent authfile", func() {
|
||||||
|
@ -74,7 +74,7 @@ EOF
|
|||||||
#
|
#
|
||||||
# So, just force a healthcheck run, then confirm that it's running.
|
# So, just force a healthcheck run, then confirm that it's running.
|
||||||
run_podman healthcheck run healthcheck_c
|
run_podman healthcheck run healthcheck_c
|
||||||
is "$output" "healthy" "output from 'podman healthcheck run'"
|
is "$output" "" "output from 'podman healthcheck run'"
|
||||||
|
|
||||||
_check_health "All healthy" "
|
_check_health "All healthy" "
|
||||||
Status | healthy
|
Status | healthy
|
||||||
|
Reference in New Issue
Block a user