mirror of
https://github.com/containers/podman.git
synced 2025-07-01 08:07:03 +08:00
Merge pull request #25681 from Honny1/fix-container-clone-with-hc
Fix container clone with configured Healthcheck
This commit is contained in:
@ -1733,6 +1733,11 @@ func (ic *ContainerEngine) ContainerClone(ctx context.Context, ctrCloneOpts enti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctrCloneOpts.CreateOpts.HealthOnFailure = spec.HealthCheckOnFailureAction.String()
|
||||||
|
ctrCloneOpts.CreateOpts.HealthLogDestination = spec.HealthLogDestination
|
||||||
|
ctrCloneOpts.CreateOpts.HealthMaxLogCount = spec.HealthMaxLogCount
|
||||||
|
ctrCloneOpts.CreateOpts.HealthMaxLogSize = spec.HealthMaxLogSize
|
||||||
|
|
||||||
err = specgenutil.FillOutSpecGen(spec, &ctrCloneOpts.CreateOpts, []string{})
|
err = specgenutil.FillOutSpecGen(spec, &ctrCloneOpts.CreateOpts, []string{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -462,6 +462,10 @@ func ConfigToSpec(rt *libpod.Runtime, specg *specgen.SpecGenerator, containerID
|
|||||||
specg.HealthMaxLogSize = define.DefaultHealthMaxLogSize
|
specg.HealthMaxLogSize = define.DefaultHealthMaxLogSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
specg.HealthConfig = conf.HealthCheckConfig
|
||||||
|
specg.StartupHealthConfig = conf.StartupHealthCheckConfig
|
||||||
|
specg.HealthCheckOnFailureAction = conf.HealthCheckOnFailureAction
|
||||||
|
|
||||||
specg.IDMappings = &conf.IDMappings
|
specg.IDMappings = &conf.IDMappings
|
||||||
specg.ContainerCreateCommand = conf.CreateCommand
|
specg.ContainerCreateCommand = conf.CreateCommand
|
||||||
if len(specg.Rootfs) == 0 {
|
if len(specg.Rootfs) == 0 {
|
||||||
|
@ -304,4 +304,33 @@ var _ = Describe("Podman container clone", func() {
|
|||||||
Expect(session.OutputToString()).Should(ContainSubstring("12=3"))
|
Expect(session.OutputToString()).Should(ContainSubstring("12=3"))
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman container clone container with healthcheck", func() {
|
||||||
|
podmanTest.PodmanExitCleanly(
|
||||||
|
"run", "-d", "--rm",
|
||||||
|
"--health-cmd", "true", "--health-start-period", "10s", "--health-interval", "10s", "--health-timeout", "10s", "--health-retries", "2",
|
||||||
|
"--health-startup-cmd", "true", "--health-startup-interval", "10s", "--health-startup-timeout", "10s", "--health-startup-retries", "2", "--health-startup-success", "1",
|
||||||
|
"--health-on-failure", "stop", "--health-max-log-count", "1", "--health-max-log-size", "1", "--health-log-destination", podmanTest.TempDir,
|
||||||
|
"--name", "parent", ALPINE, "sleep", "200",
|
||||||
|
)
|
||||||
|
|
||||||
|
podmanTest.PodmanExitCleanly("healthcheck", "run", "parent")
|
||||||
|
podmanTest.PodmanExitCleanly("container", "clone", "--run", "parent", "clone", ALPINE)
|
||||||
|
podmanTest.PodmanExitCleanly("healthcheck", "run", "clone")
|
||||||
|
|
||||||
|
parentInspect := podmanTest.PodmanExitCleanly("inspect", "parent")
|
||||||
|
parentData := parentInspect.InspectContainerToJSON()[0]
|
||||||
|
|
||||||
|
cloneInspect := podmanTest.PodmanExitCleanly("inspect", "clone")
|
||||||
|
cloneData := cloneInspect.InspectContainerToJSON()[0]
|
||||||
|
|
||||||
|
Expect(parentData.Config.HealthcheckOnFailureAction).To(Equal(cloneData.Config.HealthcheckOnFailureAction))
|
||||||
|
Expect(*parentData.Config.Healthcheck).To(Equal(*cloneData.Config.Healthcheck))
|
||||||
|
Expect(*parentData.Config.StartupHealthCheck).To(Equal(*cloneData.Config.StartupHealthCheck))
|
||||||
|
Expect(parentData.Config.HealthcheckOnFailureAction).To(Equal(cloneData.Config.HealthcheckOnFailureAction))
|
||||||
|
Expect(parentData.Config.HealthLogDestination).To(Equal(cloneData.Config.HealthLogDestination))
|
||||||
|
Expect(parentData.Config.HealthMaxLogCount).To(Equal(cloneData.Config.HealthMaxLogCount))
|
||||||
|
Expect(parentData.Config.HealthMaxLogSize).To(Equal(cloneData.Config.HealthMaxLogSize))
|
||||||
|
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user