Skip to content

Commit b80dd86

Browse files
Mark Selbyjanisz
Mark Selby
authored andcommitted
Set health check path to root (/) if empty
Fixes a regression introduced in 65c47ca. When healthchekc has not defined path in Marathon then we should map it to root path (/). Fixes: #235
1 parent f968309 commit b80dd86

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

consul/consul.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,13 @@ func (c *Consul) marathonToConsulChecks(task *apps.Task, healthChecks []apps.Hea
326326
Status: "passing",
327327
}
328328

329-
if check.Path == nil {
330-
check.Path = "/"
331-
}
332-
333329
switch check.Protocol {
334330
case "HTTP", "HTTPS", "MESOS_HTTP", "MESOS_HTTPS":
335-
if parsedURL, err := url.ParseRequestURI(check.Path); err == nil {
331+
path := "/"
332+
if check.Path != "" {
333+
path = check.Path
334+
}
335+
if parsedURL, err := url.ParseRequestURI(path); err == nil {
336336
if check.Protocol == "HTTP" || check.Protocol == "MESOS_HTTP" {
337337
parsedURL.Scheme = "http"
338338
} else {
@@ -345,7 +345,7 @@ func (c *Consul) marathonToConsulChecks(task *apps.Task, healthChecks []apps.Hea
345345
log.WithError(err).
346346
WithField("Id", task.AppID.String()).
347347
WithField("Address", serviceAddress).
348-
Warnf("Could not parse provided path: %s", check.Path)
348+
Warnf("Could not parse provided path: %s", path)
349349
}
350350
case "TCP", "MESOS_TCP":
351351
consulCheck.TCP = fmt.Sprintf("%s:%d", serviceAddress, port)

consul/consul_test.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ func TestMarathonTaskToConsulServiceMapping(t *testing.T) {
809809
assert.Equal(t, []string{"marathon", "public", "marathon-task:someTask"}, service.Tags)
810810
assert.Equal(t, 8090, service.Port)
811811
assert.Nil(t, service.Check)
812-
assert.Equal(t, 5, len(service.Checks))
812+
assert.Equal(t, 6, len(service.Checks))
813813

814814
assert.Equal(t, consulapi.AgentServiceChecks{
815815
{
@@ -818,6 +818,12 @@ func TestMarathonTaskToConsulServiceMapping(t *testing.T) {
818818
Timeout: "20s",
819819
Status: "passing",
820820
},
821+
{
822+
HTTP: "http://127.0.0.6:8090/",
823+
Interval: "60s",
824+
Timeout: "20s",
825+
Status: "passing",
826+
},
821827
{
822828
HTTP: "https://127.0.0.6:8090/secure/health?with=query",
823829
Interval: "50s",

0 commit comments

Comments
 (0)