diff --git a/nameresolution/consul/consul.go b/nameresolution/consul/consul.go index 163feaeb62..d19cf47dca 100644 --- a/nameresolution/consul/consul.go +++ b/nameresolution/consul/consul.go @@ -243,13 +243,13 @@ func getRegistrationConfig(cfg configSpec, props map[string]string) (*consul.Age } else if _, err := strconv.ParseUint(httpPort, 10, 0); err != nil { return nil, fmt.Errorf("error parsing %s: %w", nr.DaprHTTPPort, err) } - + id := appID + "-" + host + "-" + httpPort // if no health checks configured add dapr sidecar health check by default if len(cfg.Checks) == 0 { cfg.Checks = []*consul.AgentServiceCheck{ { Name: "Dapr Health Status", - CheckID: fmt.Sprintf("daprHealth:%s", appID), + CheckID: fmt.Sprintf("daprHealth:%s", id), Interval: "15s", HTTP: fmt.Sprintf("http://%s:%s/v1.0/healthz", host, httpPort), }, @@ -262,6 +262,7 @@ func getRegistrationConfig(cfg configSpec, props map[string]string) (*consul.Age } return &consul.AgentServiceRegistration{ + ID: id, Name: appID, Address: host, Port: appPortInt, diff --git a/nameresolution/consul/consul_test.go b/nameresolution/consul/consul_test.go index 028bfc2e89..b6baece198 100644 --- a/nameresolution/consul/consul_test.go +++ b/nameresolution/consul/consul_test.go @@ -501,7 +501,7 @@ func TestGetConfig(t *testing.T) { assert.Equal(t, 1, len(actual.Registration.Checks)) check := actual.Registration.Checks[0] assert.Equal(t, "Dapr Health Status", check.Name) - assert.Equal(t, "daprHealth:test-app", check.CheckID) + assert.Equal(t, "daprHealth:test-app-"+metadata.Properties[nr.HostAddress]+"-"+metadata.Properties[nr.DaprHTTPPort], check.CheckID) assert.Equal(t, "15s", check.Interval) assert.Equal(t, fmt.Sprintf("http://%s:%s/v1.0/healthz", metadata.Properties[nr.HostAddress], metadata.Properties[nr.DaprHTTPPort]), check.HTTP)