From 2f80088f3c2769356e6cf9755a34eeba4c3ad1fb Mon Sep 17 00:00:00 2001 From: Domagoj Marsic Date: Tue, 22 Mar 2022 15:00:28 +0000 Subject: [PATCH 1/2] Fix typo in command-line argument description for leader-election Signed-off-by: Domagoj Marsic --- cmd/provider/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/provider/main.go b/cmd/provider/main.go index fa43affb..449b4ad5 100644 --- a/cmd/provider/main.go +++ b/cmd/provider/main.go @@ -39,7 +39,7 @@ func main() { app = kingpin.New(filepath.Base(os.Args[0]), "SQL support for Crossplane.").DefaultEnvars() debug = app.Flag("debug", "Run with debug logging.").Short('d').Bool() syncPeriod = app.Flag("sync", "Controller manager sync period such as 300ms, 1.5h, or 2h45m").Short('s').Default("1h").Duration() - leaderElection = app.Flag("leader-election", "Use leader election for the conroller manager.").Short('l').Default("false").OverrideDefaultFromEnvar("LEADER_ELECTION").Bool() + leaderElection = app.Flag("leader-election", "Use leader election for the controller manager.").Short('l').Default("false").OverrideDefaultFromEnvar("LEADER_ELECTION").Bool() ) kingpin.MustParse(app.Parse(os.Args[1:])) From 75f97741b70a252774b6074b27640564e7583be9 Mon Sep 17 00:00:00 2001 From: Domagoj Marsic Date: Thu, 24 Mar 2022 11:11:05 +0000 Subject: [PATCH 2/2] Use default port for MySQL if not specified in the connection secret If a secret doesn't contain port, the provider won't be able to connect as it will use an empty string, which then turns to 0. An attempt to connect times out since this is not a valid port. This is the case with connection secrets created by provider-aws, for example for DBCluster. We should assume that the absence of the port key/value means that connection should happen over the default port, 3306 for MySQL servers. Signed-off-by: Domagoj Marsic --- pkg/clients/mysql/mysql.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/clients/mysql/mysql.go b/pkg/clients/mysql/mysql.go index 1d27af82..bedc4fe5 100644 --- a/pkg/clients/mysql/mysql.go +++ b/pkg/clients/mysql/mysql.go @@ -14,7 +14,8 @@ import ( ) const ( - errNotSupported = "%s not supported by mysql client" + errNotSupported = "%s not supported by mysql client" + defaultMySQLPort = "3306" ) type mySQLDB struct { @@ -28,6 +29,9 @@ func New(creds map[string][]byte) xsql.DB { // TODO(negz): Support alternative connection secret formats? endpoint := string(creds[xpv1.ResourceCredentialsSecretEndpointKey]) port := string(creds[xpv1.ResourceCredentialsSecretPortKey]) + if port == "" { + port = defaultMySQLPort + } return mySQLDB{ dsn: fmt.Sprintf("%s:%s@tcp(%s:%s)/", creds[xpv1.ResourceCredentialsSecretUserKey],