[Fix] Service tags not added to health checks

Since commit 9685bdcd0ba4b4b3adb04f9c1dd67d637ca7894e, 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 #3259.
This commit is contained in:
Yoann Fouquet 2017-11-03 10:22:52 +01:00
parent d91cb28c46
commit f4f7db0059
2 changed files with 6 additions and 0 deletions

View file

@ -1603,6 +1603,7 @@ func (a *Agent) AddService(service *structs.NodeService, chkTypes []*structs.Che
Notes: chkType.Notes, Notes: chkType.Notes,
ServiceID: service.ID, ServiceID: service.ID,
ServiceName: service.Service, ServiceName: service.Service,
ServiceTags: service.Tags,
} }
if chkType.Status != "" { if chkType.Status != "" {
check.Status = chkType.Status check.Status = chkType.Status

View file

@ -290,6 +290,7 @@ func TestAgent_AddService(t *testing.T) {
Notes: "note1", Notes: "note1",
ServiceID: "svcid1", ServiceID: "svcid1",
ServiceName: "svcname1", ServiceName: "svcname1",
ServiceTags: []string{"tag1"},
}, },
}, },
}, },
@ -329,6 +330,7 @@ func TestAgent_AddService(t *testing.T) {
Notes: "note1", Notes: "note1",
ServiceID: "svcid2", ServiceID: "svcid2",
ServiceName: "svcname2", ServiceName: "svcname2",
ServiceTags: []string{"tag2"},
}, },
"check-noname": &structs.HealthCheck{ "check-noname": &structs.HealthCheck{
Node: "node1", Node: "node1",
@ -337,6 +339,7 @@ func TestAgent_AddService(t *testing.T) {
Status: "critical", Status: "critical",
ServiceID: "svcid2", ServiceID: "svcid2",
ServiceName: "svcname2", ServiceName: "svcname2",
ServiceTags: []string{"tag2"},
}, },
"service:svcid2:3": &structs.HealthCheck{ "service:svcid2:3": &structs.HealthCheck{
Node: "node1", Node: "node1",
@ -345,6 +348,7 @@ func TestAgent_AddService(t *testing.T) {
Status: "critical", Status: "critical",
ServiceID: "svcid2", ServiceID: "svcid2",
ServiceName: "svcname2", ServiceName: "svcname2",
ServiceTags: []string{"tag2"},
}, },
"service:svcid2:4": &structs.HealthCheck{ "service:svcid2:4": &structs.HealthCheck{
Node: "node1", Node: "node1",
@ -353,6 +357,7 @@ func TestAgent_AddService(t *testing.T) {
Status: "critical", Status: "critical",
ServiceID: "svcid2", ServiceID: "svcid2",
ServiceName: "svcname2", ServiceName: "svcname2",
ServiceTags: []string{"tag2"},
}, },
}, },
}, },