Skip to content

Commit

Permalink
[Fix] Service tags not added to health checks
Browse files Browse the repository at this point in the history
Since commit 9685bdc, service tags are added to the health checks.
Otherwise, when adding a service, tags are not added to its check.

In updateSyncState, we compare the checks of the local agent with the checks of the catalog.
It appears that the service tags are different (missing in one case), and so the check is synchronized.
That increase the ModifyIndex periodically when nothing changes.

Fixed it by adding serviceTags to the check.

Note that the issue appeared in version 0.8.2.
Looks related to hashicorp#3259.
  • Loading branch information
yfouquet authored and kamaradclimber committed Dec 5, 2017
1 parent 2d6e62f commit 681d1ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,7 @@ func (a *Agent) AddService(service *structs.NodeService, chkTypes []*structs.Che
Notes: chkType.Notes,
ServiceID: service.ID,
ServiceName: service.Service,
ServiceTags: service.Tags,
}
if chkType.Status != "" {
check.Status = chkType.Status
Expand Down
5 changes: 5 additions & 0 deletions agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ func TestAgent_AddService(t *testing.T) {
Notes: "note1",
ServiceID: "svcid1",
ServiceName: "svcname1",
ServiceTags: []string{"tag1"},
},
},
},
Expand Down Expand Up @@ -430,6 +431,7 @@ func TestAgent_AddService(t *testing.T) {
Notes: "note1",
ServiceID: "svcid2",
ServiceName: "svcname2",
ServiceTags: []string{"tag2"},
},
"check-noname": &structs.HealthCheck{
Node: "node1",
Expand All @@ -438,6 +440,7 @@ func TestAgent_AddService(t *testing.T) {
Status: "critical",
ServiceID: "svcid2",
ServiceName: "svcname2",
ServiceTags: []string{"tag2"},
},
"service:svcid2:3": &structs.HealthCheck{
Node: "node1",
Expand All @@ -446,6 +449,7 @@ func TestAgent_AddService(t *testing.T) {
Status: "critical",
ServiceID: "svcid2",
ServiceName: "svcname2",
ServiceTags: []string{"tag2"},
},
"service:svcid2:4": &structs.HealthCheck{
Node: "node1",
Expand All @@ -454,6 +458,7 @@ func TestAgent_AddService(t *testing.T) {
Status: "critical",
ServiceID: "svcid2",
ServiceName: "svcname2",
ServiceTags: []string{"tag2"},
},
},
},
Expand Down

0 comments on commit 681d1ca

Please sign in to comment.