crossplane-contrib / crossplane-contrib/provider-sql

postgresql create database fails when setting owner to another role with GCP (and probably Amazon RDS)

Open
#90 1 comment 4 reactions 0 assignees View on GitHub
bug good first issue
Dominant language
Go
Stars
154
Forks
119
Avg merge
6d 17h
Merged PRs (30d)
8

Description

### What happened?
After creating a Role por postgresql if we create a database logged in as super-user on already existed PostgreSQL server on GCP (and probably on RDS) with the option (forProvider.owner: name-of-just-created-role) we get this error:

cannot create database: pq: must be member of role "name-of-just-created-role". I think the problem is exactly the same as happend to terraform devs https://github.com/hashicorp/terraform/issues/11362 .

I had no problems with postgresql instance in docker container doing the same, only on GCP.

### How can we reproduce it?
Try to create something like this on already existing GCP or RDS PostgreSQL server:

```yaml
apiVersion: postgresql.sql.crossplane.io/v1alpha1
kind: Role
metadata:
name: new-role
spec:
forProvider:
privileges:
login: true
replication: true
providerConfigRef:
name: provider-config-to-connect-to-postgresql-instance-on-gcp
writeConnectionSecretToRef:
name: new-role
namespace: default
---
apiVersion: postgresql.sql.crossplane.io/v1alpha1
kind: Database
metadata:
name: new-db
spec:
forProvider:
owner: new-role
providerConfigRef:
name: provider-config-to-connect-to-postgresql-instance-on-gcp
```

### What environment did it happen in?
Crossplane version:
1.7.1
GCP PostgreSQL instance

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the issue with the Role and Database YAML against a GCP PostgreSQL instance, then compare it with the Docker PostgreSQL behavior. Trace the Database reconciliation path that applies forProvider.owner and verify how role membership is handled on managed PostgreSQL services. Done means creating the database with the newly created role as owner succeeds without the membership error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, postgresql
Domain
cloud, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.