You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please, answer some short questions which should help us to understand your problem / question better?
Which image of the operator are you using? e.g. zalando/postgres-operator:v1.11.0
Where do you run it - cloud or metal? Kubernetes or OpenShift? Bare K8s
Are you running Postgres Operator in production? [yes | no] Yes
Type of issue? [Bug report, question, feature request, etc.], Bug Report / Question
We are using zalando operator, However when we try to create database with special character in name (to be specific hyphen -), we do notice some errors in operator logs! In this example you can find db name is app-new
I do see credentials are getting created in zalando , However while syncing roles it gives specifically following error while creating role, The strange part is app-new_ownerrole and app-new_owner_useruser got created but fails with reader, writer roles and users!
As per the code base special characters are allowed since queries are used with special character..!!
Error:
time="2024-08-30T10:48:25Z" level=error msg="could not sync roles: error executing sync statements: could not execute sync requests for users: could not create user \"app-new_reader\": pq: syntax error at or near \"-\"', 'could not set custom user \"app-new_reader\" parameters: pq: role \"app-new_reader\" does not exist', 'could not create user \"app-new_reader_user\": pq: syntax error at or near \"-\"', 'could not set custom user \"app-new_reader_user\" parameters: pq: role \"app-new_reader_user\" does not exist', 'could not create user \"app-new_public_owner\": pq: syntax error at or near \"-\"', 'could not set custom user \"app-new_public_owner\" parameters: pq: role \"app-new_public_owner\" does not exist', 'could not create user \"app-new_public_reader\": pq: syntax error at or near \"-\"', 'could not set custom user \"app-new_public_reader\" parameters: pq: role \"app-new_public_reader\" does not exist', 'could not create user \"app-new_public_writer\": pq: syntax error at or near \"-\"', 'could not set custom user \"app-new_public_writer\" parameters: pq: role \"app-new_public_writer\" does not exist', 'could not create user \"app-new_writer_user\": pq: syntax error at or near \"-\"', 'could not set custom user \"app-new_writer_user\" parameters: pq: role \"app-new_writer_user\" does not exist', 'could not create user \"app-new_writer\": pq: syntax error at or near \"-\"', 'could not set custom user \"app-new_writer\" parameters: pq: role \"app-new_writer\" does not exist" cluster-name=vmsp-platform/pg-demo pkg=cluster worker=0
Roles , Users and DBs:
root@pg-demo-0:/home/postgres# psql -h localhost -U postgres
Password for user postgres:
psql (16.2 (Ubuntu 16.2-1.pgdg22.04+1), server 14.11 (Ubuntu 14.11-1.pgdg22.04+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)
Type "help" for help.
postgres=# select * from pg_roles;
rolname | rolsuper | rolinherit | rolcreaterole | rolcreatedb | rolcanlogin | rolreplication | rolconnlimit | rolpassword | rolvaliduntil | rolbypassrls | rolconfig | oid
---------------------------+----------+------------+---------------+-------------+-------------+----------------+--------------+-------------+---------------+--------------+-----------------------------------+-------
pg_database_owner | f | t | f | f | f | f | -1 | ******** | | f | | 6171
pg_read_all_data | f | t | f | f | f | f | -1 | ******** | | f | | 6181
pg_write_all_data | f | t | f | f | f | f | -1 | ******** | | f | | 6182
pg_monitor | f | t | f | f | f | f | -1 | ******** | | f | | 3373
pg_read_all_settings | f | t | f | f | f | f | -1 | ******** | | f | | 3374
pg_read_all_stats | f | t | f | f | f | f | -1 | ******** | | f | | 3375
pg_stat_scan_tables | f | t | f | f | f | f | -1 | ******** | | f | | 3377
pg_read_server_files | f | t | f | f | f | f | -1 | ******** | | f | | 4569
pg_write_server_files | f | t | f | f | f | f | -1 | ******** | | f | | 4570
pg_execute_server_program | f | t | f | f | f | f | -1 | ******** | | f | | 4571
pg_signal_backend | f | t | f | f | f | f | -1 | ******** | | f | | 4200
postgres | t | t | t | t | t | t | -1 | ******** | | t | | 10
admin | f | t | f | t | f | f | -1 | ******** | | f | | 16384
cron_admin | f | t | f | f | f | f | -1 | ******** | | f | | 16385
zalandos | f | t | f | f | f | f | -1 | ******** | | f | | 16386
robot_zmon | f | t | f | f | f | f | -1 | ******** | | f | | 16387
standby | f | t | f | f | t | t | -1 | ******** | | f | | 16710
app1_owner_user | f | t | f | f | t | f | -1 | ******** | | f | {"search_path=\"$user\", public"} | 16720
app1_reader_user | f | t | f | f | t | f | -1 | ******** | | f | {"search_path=\"$user\", public"} | 16727
app1_writer_user | f | t | f | f | t | f | -1 | ******** | | f | {"search_path=\"$user\", public"} | 16728
app1_public_writer | f | t | f | f | f | f | -1 | ******** | | f | {"search_path=\"$user\", public"} | 16730
app1_writer | f | t | f | f | f | f | -1 | ******** | | f | {"search_path=\"$user\", public"} | 16726
app1_public_reader | f | t | f | f | f | f | -1 | ******** | | f | {"search_path=\"$user\", public"} | 16729
app-new_owner_user | f | t | f | f | t | f | -1 | ******** | | f | {"search_path=\"$user\", public"} | 16744
app1_public_owner | f | t | f | f | f | f | -1 | ******** | | f | {"search_path=\"$user\", public"} | 16725
app1_owner | f | t | f | f | f | f | -1 | ******** | | f | {"search_path=\"$user\", public"} | 16719
app-new_owner | f | t | f | f | f | f | -1 | ******** | | f | {"search_path=\"$user\", public"} | 16743
app1_reader | f | t | f | f | f | f | -1 | ******** | | f | {"search_path=\"$user\", public"} | 16723
(28 rows)
postgres=# \du
List of roles
Role name | Attributes
--------------------+------------------------------------------------------------
admin | Create DB, Cannot login
app-new_owner | Cannot login
app-new_owner_user |
app1_owner | Cannot login
app1_owner_user |
app1_public_owner | Cannot login
app1_public_reader | Cannot login
app1_public_writer | Cannot login
app1_reader | Cannot login
app1_reader_user |
app1_writer | Cannot login
app1_writer_user |
cron_admin | Cannot login
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS
robot_zmon | Cannot login
standby | Replication
zalandos | Cannot login
postgres=# \l
List of databases
Name | Owner | Encoding | Locale Provider | Collate | Ctype | ICU Locale | ICU Rules | Access privileges
-----------+------------+----------+-----------------+-------------+-------------+------------+-----------+-----------------------
app1 | app1_owner | UTF8 | libc | en_US.utf-8 | en_US.utf-8 | | |
postgres | postgres | UTF8 | libc | en_US.utf-8 | en_US.utf-8 | | |
template0 | postgres | UTF8 | libc | en_US.utf-8 | en_US.utf-8 | | | =c/postgres +
| | | | | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | libc | en_US.utf-8 | en_US.utf-8 | | | =c/postgres +
| | | | | | | | postgres=CTc/postgres
(4 rows)
For database names we have a regexp in place which does not allow hivens. Unfortunately, the PR to make it configurable got stuck at some point.
About user creation failing, I think this part (and admin template) of the SQL command does not take special characters into account. Should be easy to fix.
Thanks @FxKu for the response, Just wanted to confirm the PR to make it configurable would also support special chars in database names (i.e hyphen -). Also Can we make sure when we have special character in database name all the following process / operations (user creation, role creation and any other things) would support the same and sql command is compatible as well using double quotes..
Please, answer some short questions which should help us to understand your problem / question better?
We are using zalando operator, However when we try to create database with special character in name (to be specific hyphen
-
), we do notice some errors in operator logs! In this example you can find db name isapp-new
I do see credentials are getting created in zalando , However while syncing roles it gives specifically following error while creating role, The strange part is
app-new_owner
role andapp-new_owner_user
user got created but fails with reader, writer roles and users!As per the code base special characters are allowed since queries are used with special character..!!
Error:
Roles , Users and DBs:
Postgresql cluster:
Logs:
The text was updated successfully, but these errors were encountered: