Browse Source

[BUGFIX] Do not use interval as timeout (#14619)

Do not use interval as timeout
pull/14643/head
Daniel Graña 2 years ago committed by GitHub
parent
commit
8c98172f53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      .changelog/14619.txt
  2. 2
      agent/agent.go
  3. 47
      agent/agent_test.go

3
.changelog/14619.txt

@ -0,0 +1,3 @@
```release-note:bug
checks: Do not set interval as timeout value
```

2
agent/agent.go

@ -2287,7 +2287,7 @@ func (a *Agent) addServiceInternal(req addServiceInternalRequest) error {
intervalStr = chkType.Interval.String()
}
if chkType.Timeout != 0 {
timeoutStr = chkType.Interval.String()
timeoutStr = chkType.Timeout.String()
}
check := &structs.HealthCheck{

47
agent/agent_test.go

@ -418,6 +418,9 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
`+extraHCL)
defer a.Shutdown()
duration3s, _ := time.ParseDuration("3s")
duration10s, _ := time.ParseDuration("10s")
tests := []struct {
desc string
srv *structs.NodeService
@ -467,6 +470,50 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
},
},
},
{
"one http check with interval and duration",
&structs.NodeService{
ID: "svcid1",
Service: "svcname1",
Tags: []string{"tag1"},
Weights: nil, // nil weights...
Port: 8100,
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
// ... should be populated to avoid "IsSame" returning true during AE.
func(ns *structs.NodeService) {
ns.Weights = &structs.Weights{
Passing: 1,
Warning: 1,
}
},
[]*structs.CheckType{
{
CheckID: "check1",
Name: "name1",
HTTP: "http://localhost:8100/",
Interval: duration10s,
Timeout: duration3s,
Notes: "note1",
},
},
map[string]*structs.HealthCheck{
"check1": {
Node: "node1",
CheckID: "check1",
Name: "name1",
Interval: "10s",
Timeout: "3s",
Status: "critical",
Notes: "note1",
ServiceID: "svcid1",
ServiceName: "svcname1",
ServiceTags: []string{"tag1"},
Type: "http",
EnterpriseMeta: *structs.DefaultEnterpriseMetaInDefaultPartition(),
},
},
},
{
"multiple checks",
&structs.NodeService{

Loading…
Cancel
Save