Skip to content

Commit

Permalink
Merge pull request #3142 from cpuguy83/health_start_interval
Browse files Browse the repository at this point in the history
Add support for health start interval
  • Loading branch information
dperny committed Jul 13, 2023
2 parents 6f78b81 + 74b10bb commit bc71908
Show file tree
Hide file tree
Showing 8 changed files with 639 additions and 516 deletions.
12 changes: 7 additions & 5 deletions agent/exec/dockerapi/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,14 @@ func (c *containerConfig) healthcheck() *enginecontainer.HealthConfig {
interval, _ := gogotypes.DurationFromProto(hcSpec.Interval)
timeout, _ := gogotypes.DurationFromProto(hcSpec.Timeout)
startPeriod, _ := gogotypes.DurationFromProto(hcSpec.StartPeriod)
startInterval, _ := gogotypes.DurationFromProto(hcSpec.StartInterval)
return &enginecontainer.HealthConfig{
Test: hcSpec.Test,
Interval: interval,
Timeout: timeout,
Retries: int(hcSpec.Retries),
StartPeriod: startPeriod,
Test: hcSpec.Test,
Interval: interval,
Timeout: timeout,
Retries: int(hcSpec.Retries),
StartPeriod: startPeriod,
StartInterval: startInterval,
}
}

Expand Down
22 changes: 12 additions & 10 deletions agent/exec/dockerapi/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,25 @@ func TestHealthcheck(t *testing.T) {
Spec: api.TaskSpec{Runtime: &api.TaskSpec_Container{
Container: &api.ContainerSpec{
Healthcheck: &api.HealthConfig{
Test: []string{"a", "b", "c"},
Interval: gogotypes.DurationProto(time.Second),
Timeout: gogotypes.DurationProto(time.Minute),
Retries: 10,
StartPeriod: gogotypes.DurationProto(time.Minute),
Test: []string{"a", "b", "c"},
Interval: gogotypes.DurationProto(time.Second),
Timeout: gogotypes.DurationProto(time.Minute),
Retries: 10,
StartPeriod: gogotypes.DurationProto(time.Minute),
StartInterval: gogotypes.DurationProto(time.Minute),
},
},
}},
},
}
config := c.config()
expected := &enginecontainer.HealthConfig{
Test: []string{"a", "b", "c"},
Interval: time.Second,
Timeout: time.Minute,
Retries: 10,
StartPeriod: time.Minute,
Test: []string{"a", "b", "c"},
Interval: time.Second,
Timeout: time.Minute,
Retries: 10,
StartPeriod: time.Minute,
StartInterval: time.Minute,
}
if !reflect.DeepEqual(config.Healthcheck, expected) {
t.Fatalf("expected %#v, got %#v", expected, config.Healthcheck)
Expand Down
58 changes: 48 additions & 10 deletions api/api.pb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2621,6 +2621,36 @@ file {
}
json_name: "nonrecursive"
}
field {
name: "createmountpoint"
number: 3
label: LABEL_OPTIONAL
type: TYPE_BOOL
options {
65004: "CreateMountpoint"
}
json_name: "createmountpoint"
}
field {
name: "readonlynonrecursive"
number: 4
label: LABEL_OPTIONAL
type: TYPE_BOOL
options {
65004: "ReadOnlyNonRecursive"
}
json_name: "readonlynonrecursive"
}
field {
name: "readonlyforcerecursive"
number: 5
label: LABEL_OPTIONAL
type: TYPE_BOOL
options {
65004: "ReadOnlyForceRecursive"
}
json_name: "readonlyforcerecursive"
}
enum_type {
name: "Propagation"
value {
Expand Down Expand Up @@ -2735,8 +2765,8 @@ file {
label: LABEL_OPTIONAL
type: TYPE_UINT32
options {
65001: 0
65003: "os.FileMode"
65001: 0
}
json_name: "mode"
}
Expand Down Expand Up @@ -2904,8 +2934,8 @@ file {
type: TYPE_MESSAGE
type_name: ".google.protobuf.Duration"
options {
65001: 0
65011: 1
65001: 0
}
json_name: "delay"
}
Expand Down Expand Up @@ -3348,8 +3378,8 @@ file {
}
}
options {
62001: 0
62023: "PublishMode"
62001: 0
}
}
}
Expand Down Expand Up @@ -4055,8 +4085,8 @@ file {
label: LABEL_OPTIONAL
type: TYPE_UINT32
options {
65001: 0
65003: "os.FileMode"
65001: 0
}
json_name: "mode"
}
Expand Down Expand Up @@ -4182,6 +4212,14 @@ file {
type_name: ".google.protobuf.Duration"
json_name: "startPeriod"
}
field {
name: "start_interval"
number: 6
label: LABEL_OPTIONAL
type: TYPE_MESSAGE
type_name: ".google.protobuf.Duration"
json_name: "startInterval"
}
}
message_type {
name: "MaybeEncryptedRecord"
Expand Down Expand Up @@ -5052,8 +5090,8 @@ file {
}
}
options {
62001: 0
62023: "NodeRole"
62001: 0
}
}
syntax: "proto3"
Expand Down Expand Up @@ -9739,8 +9777,8 @@ file {
type: TYPE_MESSAGE
type_name: ".google.protobuf.Duration"
options {
65001: 0
65011: 1
65001: 0
}
json_name: "period"
}
Expand Down Expand Up @@ -10958,14 +10996,14 @@ file {
}
}
options {
63001: 0
63002: 0
63017: 1
63018: 1
63020: 1
63018: 1
63001: 0
63002: 0
63035: 0
63026: 0
63034: 0
63035: 0
}
}
file {
Expand Down
Loading

0 comments on commit bc71908

Please sign in to comment.