Skip to content

Commit

Permalink
Fix bug in TS health check
Browse files Browse the repository at this point in the history
  • Loading branch information
LorcanMcVeigh authored Mar 1, 2021
1 parent 1fa9876 commit 7c665c8
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ spec:
type: boolean
fails:
type: integer
intervals:
interval:
type: string
jitter:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ spec:
type: boolean
fails:
type: integer
intervals:
interval:
type: string
jitter:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ spec:
type: boolean
fails:
type: integer
intervals:
interval:
type: string
jitter:
type: string
Expand Down
8 changes: 4 additions & 4 deletions internal/configs/transportserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ func generateTransportServerHealthCheck(upstreamHealthCheckName string, upstream
hc = generateTransportServerHealthCheckWithDefaults(u)

hc.Enabled = u.HealthCheck.Enabled
hc.Interval = generateTime(u.HealthCheck.Interval)
hc.Jitter = generateTime(u.HealthCheck.Jitter)
hc.Timeout = generateTime(u.HealthCheck.Timeout)
hc.Interval = generateTime(u.HealthCheck.Interval, hc.Interval)
hc.Jitter = generateTime(u.HealthCheck.Jitter, hc.Jitter)
hc.Timeout = generateTime(u.HealthCheck.Timeout, hc.Timeout)

if u.HealthCheck.Fails > 0 {
hc.Fails = u.HealthCheck.Fails
Expand All @@ -152,7 +152,7 @@ func generateTransportServerHealthCheckWithDefaults(up conf_v1alpha1.Upstream) *
return &version2.StreamHealthCheck{
Enabled: false,
Timeout: "5s",
Jitter: "0",
Jitter: "0s",
Port: up.Port,
Interval: "5s",
Passes: 1,
Expand Down
21 changes: 21 additions & 0 deletions internal/configs/transportserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,27 @@ func TestGenerateTransportServerHealthChecks(t *testing.T) {
},
msg: "valid 2 health checks",
},
{
upstreams: []conf_v1alpha1.Upstream{
{
Name: "dns-tcp",
Port: 90,
HealthCheck: &conf_v1alpha1.HealthCheck{
Enabled: true,
},
},
},
expected: &version2.StreamHealthCheck{
Enabled: true,
Timeout: "5s",
Jitter: "0s",
Port: 90,
Interval: "5s",
Passes: 1,
Fails: 1,
},
msg: "return default values for health check",
},
}

for _, test := range tests {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/configuration/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ type HealthCheck struct {
Timeout string `json:"timeout"`
Jitter string `json:"jitter"`
Port int `json:"port"`
Interval string `json:"intervals"`
Interval string `json:"interval"`
Passes int `json:"passes"`
Fails int `json:"fails"`
}
Expand Down

0 comments on commit 7c665c8

Please sign in to comment.