crossplane-contrib / provider-sql

An SQL provider for @crossplane
https://crossplane.io
Apache License 2.0
108 stars 64 forks source link

Adds port twice when using connectionStrings from upbound/provider-aws-rds #191

Open lah-wag opened 1 month ago

lah-wag commented 1 month ago

What happened?

I'm creating a composition that will use manage both RDS and provider-sql databases. I've successfully created an RDS MySQL Instance using the provider-aws-rds.

apiVersion: rds.aws.upbound.io/v1beta3
kind: Instance
metadata:
  name: platform-test-db-mgxgx
spec:
  deletionPolicy: Delete
  forProvider:
    allocatedStorage: 10
    applyImmediately: true
    autoGeneratePassword: true
    autoMinorVersionUpgrade: true
    engine: mysql
    engineVersion: "8.0"
    instanceClass: db.t4g.micro
    multiAz: false
    region: eu-central-1
    skipFinalSnapshot: true
    username: root

Now I want to use provider-sql to manage the databases and users. The connectionString created by provider-aws-rds looks like this:

apiVersion: v1          
kind: Secret
type: connection.crossplane.io/v1alpha1
metadata:
  name: rds-creds-platform-test-db-mgxgx
  namespace: crossplane
data:
  address: platform-test-db-mgxgx.hashhashash.eu-central-1.rds.amazonaws.com
  attribute.password: REDACTED
  endpoint: platform-test-db-mgxgx.hashhashash.eu-central-1.rds.amazonaws.com:3306
  host: platform-test-db-mgxgx.hashhashash.eu-central-1.rds.amazonaws.com
  password: REDACTED
  port: "3306"
  username: root

Referencing it from a ProviderConfig works fine

apiVersion: mysql.sql.crossplane.io/v1alpha1
kind: ProviderConfig
metadata:
  name: mysql-provider-config-platform-test-db-mgxgx
spec:
  credentials:
    connectionSecretRef:
      name: rds-creds-platform-test-db-mgxgx
      namespace: crossplane
    source: MySQLConnectionSecret
  tls: preferred

When creating a database there's an issue with the port being added twice:

kubectl get events -w
0s (x9 over 1s)          Warning   CannotObserveExternalResource   Database/rds-test                                                
cannot select database: dial tcp: lookup platform-test-db-mgxgx.hashhashhas.eu-central-1.rds.amazonaws.com:3306:3306: no such host

What environment did it happen in?

Cloud provider: AWS EKS

$ crossplane version
Client Version: v1.17.0
Server Version: v1.17.0
$ kubectl version
Client Version: v1.31.1
Kustomize Version: v5.4.2
Server Version: v1.29.7-eks-2f46c53
lah-wag commented 1 month ago

Would be solved by: https://github.com/crossplane-contrib/provider-sql/pull/154 Possible upstream issue: https://github.com/crossplane-contrib/provider-upjet-aws/issues/778