crossplane-contrib / crossplane-contrib/provider-sql

Use default Mysql port if not specified in the connection secret

Open
#76 0 comments 2 reactions 0 assignees View on GitHub
db:mysql enhancement
Dominant language
Go
Stars
154
Forks
119
Avg merge
6d 17h
Merged PRs (30d)
8

Description

### What problem are you facing?

If a secret containing connection parameters for Mysql server doesn't contain `port`, the connection will timeout when attempting to use the provider, e.g. when creating a user:

```
CannotObserveExternalResource user/test-user cannot select user: dial tcp 10.x.x.x:0: i/o timeout
```

The problem is that provider-aws doesn't write `port` data for DB cluster (maybe for others as well). While it makes sense to address this in provider-aws, I also believe it makes sense to set a default port in provider-sql, as user's intention would likely be to connect over 3306 (instead of 0).

Example secret created by provider-aws:

```
apiVersion: v1
data:
endpoint: [...]
password: [...]
username: [...]
kind: Secret
metadata:
creationTimestamp: "2022-03-22T11:28:56Z"
name: test-db-connection
namespace: default
ownerReferences:
- apiVersion: rds.aws.crossplane.io/v1alpha1
controller: true
kind: DBCluster
name: cluster-kw87c
uid: [...]
resourceVersion: [...]
uid: [...]
type: connection.crossplane.io/v1alpha1
```

### How could Crossplane help solve your problem?

Assume that the absence of port in the connection secret means that the connection attempt should happen over the default port.

I'd be happy to submit a PR if this proposal makes sense. As far as I can tell the required change is in `pkg/clients/mysql/mysql.go`, where we could put a default port constant, and use it if the port is an empty string.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.