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 == "" {
|
if name == "" {
|
||||||
name = fmt.Sprintf("Service '%s' check", service.Service)
|
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{
|
check := &structs.HealthCheck{
|
||||||
Node: a.config.NodeName,
|
Node: a.config.NodeName,
|
||||||
CheckID: types.CheckID(checkID),
|
CheckID: types.CheckID(checkID),
|
||||||
Name: name,
|
Name: name,
|
||||||
|
Interval: intervalStr,
|
||||||
|
Timeout: timeoutStr,
|
||||||
Status: api.HealthCritical,
|
Status: api.HealthCritical,
|
||||||
Notes: chkType.Notes,
|
Notes: chkType.Notes,
|
||||||
ServiceID: service.ID,
|
ServiceID: service.ID,
|
||||||
|
|
|
@ -452,6 +452,8 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
|
||||||
Node: "node1",
|
Node: "node1",
|
||||||
CheckID: "check1",
|
CheckID: "check1",
|
||||||
Name: "name1",
|
Name: "name1",
|
||||||
|
Interval: "",
|
||||||
|
Timeout: "", // these are empty because a TTL was provided
|
||||||
Status: "critical",
|
Status: "critical",
|
||||||
Notes: "note1",
|
Notes: "note1",
|
||||||
ServiceID: "svcid1",
|
ServiceID: "svcid1",
|
||||||
|
@ -500,6 +502,8 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
|
||||||
Node: "node1",
|
Node: "node1",
|
||||||
CheckID: "check1",
|
CheckID: "check1",
|
||||||
Name: "name1",
|
Name: "name1",
|
||||||
|
Interval: "",
|
||||||
|
Timeout: "", // these are empty bcause a TTL was provided
|
||||||
Status: "critical",
|
Status: "critical",
|
||||||
Notes: "note1",
|
Notes: "note1",
|
||||||
ServiceID: "svcid2",
|
ServiceID: "svcid2",
|
||||||
|
@ -512,6 +516,8 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
|
||||||
Node: "node1",
|
Node: "node1",
|
||||||
CheckID: "check-noname",
|
CheckID: "check-noname",
|
||||||
Name: "Service 'svcname2' check",
|
Name: "Service 'svcname2' check",
|
||||||
|
Interval: "",
|
||||||
|
Timeout: "", // these are empty because a TTL was provided
|
||||||
Status: "critical",
|
Status: "critical",
|
||||||
ServiceID: "svcid2",
|
ServiceID: "svcid2",
|
||||||
ServiceName: "svcname2",
|
ServiceName: "svcname2",
|
||||||
|
@ -523,6 +529,8 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
|
||||||
Node: "node1",
|
Node: "node1",
|
||||||
CheckID: "service:svcid2:3",
|
CheckID: "service:svcid2:3",
|
||||||
Name: "check-noid",
|
Name: "check-noid",
|
||||||
|
Interval: "",
|
||||||
|
Timeout: "", // these are empty becuase a TTL was provided
|
||||||
Status: "critical",
|
Status: "critical",
|
||||||
ServiceID: "svcid2",
|
ServiceID: "svcid2",
|
||||||
ServiceName: "svcname2",
|
ServiceName: "svcname2",
|
||||||
|
@ -534,6 +542,8 @@ func testAgent_AddService(t *testing.T, extraHCL string) {
|
||||||
Node: "node1",
|
Node: "node1",
|
||||||
CheckID: "service:svcid2:4",
|
CheckID: "service:svcid2:4",
|
||||||
Name: "Service 'svcname2' check",
|
Name: "Service 'svcname2' check",
|
||||||
|
Interval: "",
|
||||||
|
Timeout: "", // these are empty because a TTL was provided
|
||||||
Status: "critical",
|
Status: "critical",
|
||||||
ServiceID: "svcid2",
|
ServiceID: "svcid2",
|
||||||
ServiceName: "svcname2",
|
ServiceName: "svcname2",
|
||||||
|
|
Loading…
Reference in New Issue