Skip to content

Commit

Permalink
Merge pull request #71 from vshn/fix/wrong_endpoint_address
Browse files Browse the repository at this point in the history
Set correct instance_id in metrics endpoint URL
  • Loading branch information
TheBigLee authored Mar 21, 2022
2 parents 40a58f0 + b28922c commit e8da29d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions pkg/brokerapi/brokerapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1082,9 +1082,9 @@ func (ts *EnvTestSuite) TestBrokerAPI_Bind() {
"jdbcUrl": "***",
"jdbcUrlMariaDb": "***",
"metricsEndpoints": []string{
"http://1-2-1-mariadb-0.dbaas-test-cluster.metrics.example.tld",
"http://1-2-1-mariadb-1.dbaas-test-cluster.metrics.example.tld",
"http://1-2-1-mariadb-2.dbaas-test-cluster.metrics.example.tld",
"http://1-1-1-mariadb-0.dbaas-test-cluster.metrics.example.tld",
"http://1-1-1-mariadb-1.dbaas-test-cluster.metrics.example.tld",
"http://1-1-1-mariadb-2.dbaas-test-cluster.metrics.example.tld",
},
},
},
Expand Down
12 changes: 6 additions & 6 deletions pkg/crossplane/service_mariadb_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (msb MariadbDatabaseServiceBinder) Bind(ctx context.Context, bindingID stri
return nil, fmt.Errorf("Could not get parent instance: %w", err)
}
cn := parent.GetLabels()["service.syn.tools/cluster"]
creds := createCredentials(endpoint, bindingID, pw, msb.instance.ID(), cn, msb.cp.config.EnableMetrics, msb.cp.config.MetricsDomain)
creds := createCredentials(endpoint, bindingID, pw, msb.instance.ID(), msb.instance.Labels.ParentID, cn, msb.cp.config.EnableMetrics, msb.cp.config.MetricsDomain)

return creds, nil
}
Expand Down Expand Up @@ -166,7 +166,7 @@ func (msb MariadbDatabaseServiceBinder) GetBinding(ctx context.Context, bindingI
}
cn := parent.GetLabels()["service.syn.tools/cluster"]
pw := string(secret.Data[xrv1.ResourceCredentialsSecretPasswordKey])
creds := createCredentials(endpoint, bindingID, pw, msb.instance.ID(), cn, msb.cp.config.EnableMetrics, msb.cp.config.MetricsDomain)
creds := createCredentials(endpoint, bindingID, pw, msb.instance.ID(), msb.instance.Labels.ParentID, cn, msb.cp.config.EnableMetrics, msb.cp.config.MetricsDomain)

return creds, nil
}
Expand Down Expand Up @@ -250,7 +250,7 @@ func mapMariadbEndpoint(data map[string][]byte) (*Endpoint, error) {
}, nil
}

func createCredentials(endpoint *Endpoint, username, password, database, clusterName string, metricsEnabled bool, metricsDomain string) Credentials {
func createCredentials(endpoint *Endpoint, username, password, database, databaseParent string, clusterName string, metricsEnabled bool, metricsDomain string) Credentials {
uri := fmt.Sprintf("mysql://%s:%s@%s:%d/%s?reconnect=true", username, password, endpoint.Host, endpoint.Port, database)

creds := Credentials{
Expand All @@ -268,9 +268,9 @@ func createCredentials(endpoint *Endpoint, username, password, database, cluster
}
if metricsEnabled {
creds["metricsEndpoints"] = []string{
fmt.Sprintf("http://%s-mariadb-0.%s.%s", database, clusterName, metricsDomain),
fmt.Sprintf("http://%s-mariadb-1.%s.%s", database, clusterName, metricsDomain),
fmt.Sprintf("http://%s-mariadb-2.%s.%s", database, clusterName, metricsDomain),
fmt.Sprintf("http://%s-mariadb-0.%s.%s", databaseParent, clusterName, metricsDomain),
fmt.Sprintf("http://%s-mariadb-1.%s.%s", databaseParent, clusterName, metricsDomain),
fmt.Sprintf("http://%s-mariadb-2.%s.%s", databaseParent, clusterName, metricsDomain),
}
}

Expand Down

0 comments on commit e8da29d

Please sign in to comment.