mirror of https://github.com/docker/cli.git
stacks: Add support for start interval
Signed-off-by: Brian Goff <cpuguy83@gmail.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
9df7be5d5e
commit
defa52b8c6
|
@ -436,7 +436,7 @@ func convertHealthcheck(healthcheck *composetypes.HealthCheckConfig) (*container
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
timeout, interval, startPeriod time.Duration
|
timeout, interval, startPeriod, startInterval time.Duration
|
||||||
retries int
|
retries int
|
||||||
)
|
)
|
||||||
if healthcheck.Disable {
|
if healthcheck.Disable {
|
||||||
|
@ -457,6 +457,9 @@ func convertHealthcheck(healthcheck *composetypes.HealthCheckConfig) (*container
|
||||||
if healthcheck.StartPeriod != nil {
|
if healthcheck.StartPeriod != nil {
|
||||||
startPeriod = time.Duration(*healthcheck.StartPeriod)
|
startPeriod = time.Duration(*healthcheck.StartPeriod)
|
||||||
}
|
}
|
||||||
|
if healthcheck.StartInterval != nil {
|
||||||
|
startInterval = time.Duration(*healthcheck.StartInterval)
|
||||||
|
}
|
||||||
if healthcheck.Retries != nil {
|
if healthcheck.Retries != nil {
|
||||||
retries = int(*healthcheck.Retries)
|
retries = int(*healthcheck.Retries)
|
||||||
}
|
}
|
||||||
|
@ -466,6 +469,7 @@ func convertHealthcheck(healthcheck *composetypes.HealthCheckConfig) (*container
|
||||||
Interval: interval,
|
Interval: interval,
|
||||||
Retries: retries,
|
Retries: retries,
|
||||||
StartPeriod: startPeriod,
|
StartPeriod: startPeriod,
|
||||||
|
StartInterval: startInterval,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,16 +124,23 @@ func TestConvertHealthcheck(t *testing.T) {
|
||||||
retries := uint64(10)
|
retries := uint64(10)
|
||||||
timeout := composetypes.Duration(30 * time.Second)
|
timeout := composetypes.Duration(30 * time.Second)
|
||||||
interval := composetypes.Duration(2 * time.Millisecond)
|
interval := composetypes.Duration(2 * time.Millisecond)
|
||||||
|
startPeriod := composetypes.Duration(time.Minute)
|
||||||
|
startInterval := composetypes.Duration(1 * time.Second)
|
||||||
|
|
||||||
source := &composetypes.HealthCheckConfig{
|
source := &composetypes.HealthCheckConfig{
|
||||||
Test: []string{"EXEC", "touch", "/foo"},
|
Test: []string{"EXEC", "touch", "/foo"},
|
||||||
Timeout: &timeout,
|
Timeout: &timeout,
|
||||||
Interval: &interval,
|
Interval: &interval,
|
||||||
Retries: &retries,
|
Retries: &retries,
|
||||||
|
StartPeriod: &startPeriod,
|
||||||
|
StartInterval: &startInterval,
|
||||||
}
|
}
|
||||||
expected := &container.HealthConfig{
|
expected := &container.HealthConfig{
|
||||||
Test: source.Test,
|
Test: source.Test,
|
||||||
Timeout: time.Duration(timeout),
|
Timeout: time.Duration(timeout),
|
||||||
Interval: time.Duration(interval),
|
Interval: time.Duration(interval),
|
||||||
|
StartPeriod: time.Duration(startPeriod),
|
||||||
|
StartInterval: time.Duration(startInterval),
|
||||||
Retries: 10,
|
Retries: 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,6 +158,7 @@ services:
|
||||||
timeout: 1s
|
timeout: 1s
|
||||||
retries: 5
|
retries: 5
|
||||||
start_period: 15s
|
start_period: 15s
|
||||||
|
start_interval: 1s
|
||||||
|
|
||||||
# Any valid image reference - repo, tag, id, sha
|
# Any valid image reference - repo, tag, id, sha
|
||||||
image: redis
|
image: redis
|
||||||
|
|
|
@ -159,6 +159,7 @@ func services(workingDir, homeDir string) []types.ServiceConfig {
|
||||||
Timeout: durationPtr(1 * time.Second),
|
Timeout: durationPtr(1 * time.Second),
|
||||||
Retries: uint64Ptr(5),
|
Retries: uint64Ptr(5),
|
||||||
StartPeriod: durationPtr(15 * time.Second),
|
StartPeriod: durationPtr(15 * time.Second),
|
||||||
|
StartInterval: durationPtr(1 * time.Second),
|
||||||
},
|
},
|
||||||
Hostname: "foo",
|
Hostname: "foo",
|
||||||
Image: "redis",
|
Image: "redis",
|
||||||
|
|
|
@ -252,7 +252,8 @@
|
||||||
"timeout": "1s",
|
"timeout": "1s",
|
||||||
"interval": "10s",
|
"interval": "10s",
|
||||||
"retries": 5,
|
"retries": 5,
|
||||||
"start_period": "15s"
|
"start_period": "15s",
|
||||||
|
"start_interval": "1s"
|
||||||
},
|
},
|
||||||
"image": "redis",
|
"image": "redis",
|
||||||
"ipc": "host",
|
"ipc": "host",
|
||||||
|
|
|
@ -126,6 +126,7 @@ services:
|
||||||
interval: 10s
|
interval: 10s
|
||||||
retries: 5
|
retries: 5
|
||||||
start_period: 15s
|
start_period: 15s
|
||||||
|
start_interval: 1s
|
||||||
image: redis
|
image: redis
|
||||||
ipc: host
|
ipc: host
|
||||||
labels:
|
labels:
|
||||||
|
|
|
@ -346,7 +346,8 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"timeout": {"type": "string", "format": "duration"},
|
"timeout": {"type": "string", "format": "duration"},
|
||||||
"start_period": {"type": "string", "format": "duration"}
|
"start_period": {"type": "string", "format": "duration"},
|
||||||
|
"start_interval": {"type": "string", "format": "duration"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"deployment": {
|
"deployment": {
|
||||||
|
|
|
@ -281,6 +281,7 @@ type HealthCheckConfig struct {
|
||||||
Interval *Duration `yaml:",omitempty" json:"interval,omitempty"`
|
Interval *Duration `yaml:",omitempty" json:"interval,omitempty"`
|
||||||
Retries *uint64 `yaml:",omitempty" json:"retries,omitempty"`
|
Retries *uint64 `yaml:",omitempty" json:"retries,omitempty"`
|
||||||
StartPeriod *Duration `mapstructure:"start_period" yaml:"start_period,omitempty" json:"start_period,omitempty"`
|
StartPeriod *Duration `mapstructure:"start_period" yaml:"start_period,omitempty" json:"start_period,omitempty"`
|
||||||
|
StartInterval *Duration `mapstructure:"start_interval" yaml:"start_interval,omitempty" json:"start_interval,omitempty"`
|
||||||
Disable bool `yaml:",omitempty" json:"disable,omitempty"`
|
Disable bool `yaml:",omitempty" json:"disable,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue