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

Do not use interval as timeout
This commit is contained in:
Daniel Graña 2022-09-15 13:39:48 -03:00 committed by GitHub
parent 3095d4d702
commit 13ac6356a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 1 deletions

3
.changelog/14619.txt Normal file
View File

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

View File

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

View File

@ -418,6 +418,9 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
`+extraHCL) `+extraHCL)
defer a.Shutdown() defer a.Shutdown()
duration3s, _ := time.ParseDuration("3s")
duration10s, _ := time.ParseDuration("10s")
tests := []struct { tests := []struct {
desc string desc string
srv *structs.NodeService 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", "multiple checks",
&structs.NodeService{ &structs.NodeService{