canonical / postgresql-k8s-operator

A Charmed Operator for running PostgreSQL on Kubernetes
https://charmhub.io/postgresql-k8s
Apache License 2.0
10 stars 20 forks source link

Error on use of extra_user_roles="admin" with DatabaseRequires #192

Closed AmberCharitos closed 1 year ago

AmberCharitos commented 1 year ago

Steps to reproduce

# clone trino charm repo:
git clone https://github.com/canonical/trino-k8s-operator.git

# checkout postgres-relation branch
git checkout postgres-relation

# pack charm
cd trino-k8s-charm
charmcraft pack

# deploy trino charm
juju deploy ./trino-k8s_ubuntu-22.04-amd64.charm --resource trino-image=trinodb/trino:418

# deploy postgres charm
juju deploy postgresql-k8s --channel 14/stable

# relate charms
juju relate postgresql-k8s:database trino-k8s:postgresql_db

Expected behavior

A relation is created between trino-k8s charm and postgresql-k8s charm, resulting in db_context being logged for the admin user.

Actual behavior

Postgres Charm throw an error and goes into error status

Versions

Operating system: Ubuntu 22.04.1 LTS

Juju CLI: 3.1.2-genericlinux-amd64

Juju agent: 3.1.2

Charm revision: 14.7

microk8s: MicroK8s v1.25.10 revision 5354

Log output

Juju debug log: log.txt

2023-06-22T11:32:29.318Z [container-agent] 2023-06-22 11:32:29 ERROR juju-log database:134: Failed to create user: syntax error at or near ";"
2023-06-22T11:32:29.318Z [container-agent] LINE 1: ...134" WITH LOGIN ENCRYPTED PASSWORD 'QN20iew3AUq51Yve' admin;
2023-06-22T11:32:29.318Z [container-agent]                                                                       ^
2023-06-22T11:32:29.318Z [container-agent] 
2023-06-22T11:32:29.324Z [container-agent] 2023-06-22 11:32:29 ERROR juju-log database:134: 
2023-06-22T11:32:29.324Z [container-agent] Traceback (most recent call last):
2023-06-22T11:32:29.324Z [container-agent]   File "/var/lib/juju/agents/unit-postgres-two-0/charm/lib/charms/postgresql_k8s/v0/postgresql.py", line 174, in create_user
2023-06-22T11:32:29.324Z [container-agent]     cursor.execute(
2023-06-22T11:32:29.324Z [container-agent] psycopg2.errors.SyntaxError: syntax error at or near ";"
2023-06-22T11:32:29.324Z [container-agent] LINE 1: ...134" WITH LOGIN ENCRYPTED PASSWORD 'QN20iew3AUq51Yve' admin;
2023-06-22T11:32:29.324Z [container-agent]                                                                       ^
2023-06-22T11:32:29.324Z [container-agent] 
2023-06-22T11:32:29.324Z [container-agent] 
2023-06-22T11:32:29.324Z [container-agent] During handling of the above exception, another exception occurred:
2023-06-22T11:32:29.324Z [container-agent] 
2023-06-22T11:32:29.324Z [container-agent] Traceback (most recent call last):
2023-06-22T11:32:29.324Z [container-agent]   File "/var/lib/juju/agents/unit-postgres-two-0/charm/src/relations/postgresql_provider.py", line 86, in _on_database_requested
2023-06-22T11:32:29.324Z [container-agent]     self.charm.postgresql.create_user(user, password, extra_user_roles=extra_user_roles)
2023-06-22T11:32:29.324Z [container-agent]   File "/var/lib/juju/agents/unit-postgres-two-0/charm/lib/charms/postgresql_k8s/v0/postgresql.py", line 179, in create_user
2023-06-22T11:32:29.324Z [container-agent]     raise PostgreSQLCreateUserError()
2023-06-22T11:32:29.324Z [container-agent] charms.postgresql_k8s.v0.postgresql.PostgreSQLCreateUserError

Additional context

github-actions[bot] commented 1 year ago

https://warthogs.atlassian.net/browse/DPE-2167

marceloneppel commented 1 year ago

Hi @AmberCharitos!

This issue should be fixed by https://github.com/canonical/postgresql-k8s-operator/pull/201.

AmberCharitos commented 1 year ago

Thank you @marceloneppel !

marceloneppel commented 1 year ago

@AmberCharitos, revision 116 from 14/edge channel has the fix.