fix: handle missing healthcheck keys in config (#1810)

pull/1811/head
nils måsén 1 year ago committed by GitHub
parent dd54055143
commit c4d493881d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -305,6 +305,7 @@ func (c Container) GetCreateConfig() *dockercontainer.Config {
}
// Clear HEALTHCHECK configuration (if default)
if config.Healthcheck != nil && imageConfig.Healthcheck != nil {
if util.SliceEqual(config.Healthcheck.Test, imageConfig.Healthcheck.Test) {
config.Healthcheck.Test = nil
}
@ -324,6 +325,7 @@ func (c Container) GetCreateConfig() *dockercontainer.Config {
if config.Healthcheck.StartPeriod == imageConfig.Healthcheck.StartPeriod {
config.Healthcheck.StartPeriod = 0
}
}
config.Env = util.SliceSubtract(config.Env, imageConfig.Env)

@ -124,6 +124,36 @@ var _ = Describe("the container", func() {
}))
})
})
When("container healthcheck config is empty", func() {
It("should not panic", func() {
c := MockContainer(WithImageHealthcheck(dc.HealthConfig{
Test: []string{"/usr/bin/sleep", "10s"},
Interval: 10,
Timeout: 60,
StartPeriod: 30,
Retries: 10,
}))
Expect(c.GetCreateConfig().Healthcheck).To(BeNil())
})
})
When("container image healthcheck config is empty", func() {
It("should not panic", func() {
c := MockContainer(WithHealthcheck(dc.HealthConfig{
Test: []string{"/usr/bin/sleep", "1s"},
Interval: 30,
Timeout: 30,
StartPeriod: 10,
Retries: 2,
}))
Expect(c.GetCreateConfig().Healthcheck).To(Equal(&dc.HealthConfig{
Test: []string{"/usr/bin/sleep", "1s"},
Interval: 30,
Timeout: 30,
StartPeriod: 10,
Retries: 2,
}))
})
})
})
When("asked for metadata", func() {
var c *Container

Loading…
Cancel
Save