mirror of
https://github.com/containers/podman.git
synced 2025-06-21 09:28:09 +08:00
Merge pull request #5994 from giuseppe/fix-healthchecks
v2, podman: fix healthchecks
This commit is contained in:
@ -203,10 +203,17 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
|
|||||||
s.User = c.User
|
s.User = c.User
|
||||||
inputCommand := args[1:]
|
inputCommand := args[1:]
|
||||||
if len(c.HealthCmd) > 0 {
|
if len(c.HealthCmd) > 0 {
|
||||||
|
if c.NoHealthCheck {
|
||||||
|
return errors.New("Cannot specify both --no-healthcheck and --health-cmd")
|
||||||
|
}
|
||||||
s.HealthConfig, err = makeHealthCheckFromCli(c.HealthCmd, c.HealthInterval, c.HealthRetries, c.HealthTimeout, c.HealthStartPeriod)
|
s.HealthConfig, err = makeHealthCheckFromCli(c.HealthCmd, c.HealthInterval, c.HealthRetries, c.HealthTimeout, c.HealthStartPeriod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
} else if c.NoHealthCheck {
|
||||||
|
s.HealthConfig = &manifest.Schema2HealthConfig{
|
||||||
|
Test: []string{"NONE"},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
userNS := ns.UsernsMode(c.UserNS)
|
userNS := ns.UsernsMode(c.UserNS)
|
||||||
@ -624,10 +631,15 @@ func makeHealthCheckFromCli(inCmd, interval string, retries uint, timeout, start
|
|||||||
|
|
||||||
// first try to parse option value as JSON array of strings...
|
// first try to parse option value as JSON array of strings...
|
||||||
cmd := []string{}
|
cmd := []string{}
|
||||||
err := json.Unmarshal([]byte(inCmd), &cmd)
|
|
||||||
if err != nil {
|
if inCmd == "none" {
|
||||||
// ...otherwise pass it to "/bin/sh -c" inside the container
|
cmd = []string{"NONE"}
|
||||||
cmd = []string{"CMD-SHELL", inCmd}
|
} else {
|
||||||
|
err := json.Unmarshal([]byte(inCmd), &cmd)
|
||||||
|
if err != nil {
|
||||||
|
// ...otherwise pass it to "/bin/sh -c" inside the container
|
||||||
|
cmd = []string{"CMD-SHELL", inCmd}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
hc := manifest.Schema2HealthConfig{
|
hc := manifest.Schema2HealthConfig{
|
||||||
Test: cmd,
|
Test: cmd,
|
||||||
|
@ -25,6 +25,13 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.HealthConfig == nil {
|
||||||
|
s.HealthConfig, err = newImage.GetHealthCheck(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Image stop signal
|
// Image stop signal
|
||||||
if s.StopSignal == nil {
|
if s.StopSignal == nil {
|
||||||
stopSignal, err := newImage.StopSignal(ctx)
|
stopSignal, err := newImage.StopSignal(ctx)
|
||||||
|
@ -18,7 +18,6 @@ var _ = Describe("Podman healthcheck run", func() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
Skip(v2fail)
|
|
||||||
tempdir, err = CreateTempDirInTempDir()
|
tempdir, err = CreateTempDirInTempDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
Reference in New Issue
Block a user