Skip to content

Commit

Permalink
Merge pull request #3642 from yfouquet/master
Browse files Browse the repository at this point in the history
[Fix] Service tags not added to health checks
  • Loading branch information
slackpad authored Dec 14, 2017
2 parents 76c25dc + 16cc432 commit f491a55
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1592,6 +1592,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 @@ -290,6 +290,7 @@ func TestAgent_AddService(t *testing.T) {
Notes: "note1",
ServiceID: "svcid1",
ServiceName: "svcname1",
ServiceTags: []string{"tag1"},
},
},
},
Expand Down Expand Up @@ -329,6 +330,7 @@ func TestAgent_AddService(t *testing.T) {
Notes: "note1",
ServiceID: "svcid2",
ServiceName: "svcname2",
ServiceTags: []string{"tag2"},
},
"check-noname": &structs.HealthCheck{
Node: "node1",
Expand All @@ -337,6 +339,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 @@ -345,6 +348,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 @@ -353,6 +357,7 @@ func TestAgent_AddService(t *testing.T) {
Status: "critical",
ServiceID: "svcid2",
ServiceName: "svcname2",
ServiceTags: []string{"tag2"},
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion website/source/api/agent/check.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ $ curl \
"Notes": "",
"Output": "",
"ServiceID": "redis",
"ServiceName": "redis"
"ServiceName": "redis",
"ServiceTags": ["primary"]
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion website/source/api/agent/service.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $ curl \
"redis": {
"ID": "redis",
"Service": "redis",
"Tags": null,
"Tags": [],
"Address": "",
"Port": 8000
}
Expand Down
6 changes: 3 additions & 3 deletions website/source/api/health.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ $ curl \
"Output": "",
"ServiceID": "",
"ServiceName": "",
"ServiceTags": null
"ServiceTags": []
},
{
"ID": "40e4a748-2192-161a-0510-9bf59fe950b5",
Expand Down Expand Up @@ -239,7 +239,7 @@ $ curl \
"Output": "",
"ServiceID": "",
"ServiceName": "",
"ServiceTags": null
"ServiceTags": []
}
]
}
Expand Down Expand Up @@ -303,7 +303,7 @@ $ curl \
"Output": "",
"ServiceID": "",
"ServiceName": "",
"ServiceTags": null
"ServiceTags": []
},
{
"Node": "foobar",
Expand Down
2 changes: 1 addition & 1 deletion website/source/intro/getting-started/checks.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ can be run on either node):

```text
vagrant@n1:~$ curl http://localhost:8500/v1/health/state/critical
[{"Node":"agent-two","CheckID":"service:web","Name":"Service 'web' check","Status":"critical","Notes":"","ServiceID":"web","ServiceName":"web"}]
[{"Node":"agent-two","CheckID":"service:web","Name":"Service 'web' check","Status":"critical","Notes":"","ServiceID":"web","ServiceName":"web","ServiceTags":["rails"]}]
```

We can see that there is only a single check, our `web` service check, in the
Expand Down

0 comments on commit f491a55

Please sign in to comment.