mirror of https://github.com/status-im/consul.git
checks: populate interval and timeout when registering services (#11138)
This commit is contained in:
parent
362753cad7
commit
602e08ada7
|
@ -0,0 +1,3 @@
|
|||
```release-note:bug
|
||||
checks: populate interval and timeout when registering services
|
||||
```
|
|
@ -2120,10 +2120,22 @@ func (a *Agent) addServiceInternal(req addServiceInternalRequest) error {
|
|||
if name == "" {
|
||||
name = fmt.Sprintf("Service '%s' check", service.Service)
|
||||
}
|
||||
|
||||
var intervalStr string
|
||||
var timeoutStr string
|
||||
if chkType.Interval != 0 {
|
||||
intervalStr = chkType.Interval.String()
|
||||
}
|
||||
if chkType.Timeout != 0 {
|
||||
timeoutStr = chkType.Interval.String()
|
||||
}
|
||||
|
||||
check := &structs.HealthCheck{
|
||||
Node: a.config.NodeName,
|
||||
CheckID: types.CheckID(checkID),
|
||||
Name: name,
|
||||
Interval: intervalStr,
|
||||
Timeout: timeoutStr,
|
||||
Status: api.HealthCritical,
|
||||
Notes: chkType.Notes,
|
||||
ServiceID: service.ID,
|
||||
|
|
|
@ -452,6 +452,8 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
|
|||
Node: "node1",
|
||||
CheckID: "check1",
|
||||
Name: "name1",
|
||||
Interval: "",
|
||||
Timeout: "", // these are empty because a TTL was provided
|
||||
Status: "critical",
|
||||
Notes: "note1",
|
||||
ServiceID: "svcid1",
|
||||
|
@ -500,6 +502,8 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
|
|||
Node: "node1",
|
||||
CheckID: "check1",
|
||||
Name: "name1",
|
||||
Interval: "",
|
||||
Timeout: "", // these are empty bcause a TTL was provided
|
||||
Status: "critical",
|
||||
Notes: "note1",
|
||||
ServiceID: "svcid2",
|
||||
|
@ -512,6 +516,8 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
|
|||
Node: "node1",
|
||||
CheckID: "check-noname",
|
||||
Name: "Service 'svcname2' check",
|
||||
Interval: "",
|
||||
Timeout: "", // these are empty because a TTL was provided
|
||||
Status: "critical",
|
||||
ServiceID: "svcid2",
|
||||
ServiceName: "svcname2",
|
||||
|
@ -523,6 +529,8 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
|
|||
Node: "node1",
|
||||
CheckID: "service:svcid2:3",
|
||||
Name: "check-noid",
|
||||
Interval: "",
|
||||
Timeout: "", // these are empty becuase a TTL was provided
|
||||
Status: "critical",
|
||||
ServiceID: "svcid2",
|
||||
ServiceName: "svcname2",
|
||||
|
@ -534,6 +542,8 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
|
|||
Node: "node1",
|
||||
CheckID: "service:svcid2:4",
|
||||
Name: "Service 'svcname2' check",
|
||||
Interval: "",
|
||||
Timeout: "", // these are empty because a TTL was provided
|
||||
Status: "critical",
|
||||
ServiceID: "svcid2",
|
||||
ServiceName: "svcname2",
|
||||
|
|
Loading…
Reference in New Issue