alexandrevilain / temporal-operator

Temporal Kubernetes Operator
https://temporal-operator.pages.dev/
Apache License 2.0
164 stars 37 forks source link

need to disable create-default-database.sh and create-visibility-database.sh steps #650

Closed bkcsfi closed 8 months ago

bkcsfi commented 8 months ago

Hi,

I am trying to setup a temporal cluster with postgres based on cloudnative-pg

The database and user already exists when the temporal operator starts.

However the schema setup process fails with this error:

Unable to create SQL database. {"error": "pq: permission denied to create database", "logging-call-at": "handler.go:94"}

I believe its failing because the create-default-database.sh script always attempts to create the database.

I've tried editing the configmap in argocd and k9s to comment out this script, but I can't seem to change it.

Unfortunately the temporal-sql-tool doesn't appear to support a 'create if not exists' option.

Any suggestions on how to get temporal-operator to bypass this step since the databases already exist?

bkcsfi commented 8 months ago

I found a workaround.

I reviewed the source for the temporal-sql-tool to see how it handles the create process. That code is supposed to recognize that the database already exists. However the create step fails because the db user is not authorized to create a database.

My workaround was to change the cloudnative-pg configuration so that the default database user is also a superuser. This is not a great solution, but moves things forward.

I think I will open a case with temporal to see if the temporal-sql-tool can handle this situation better.

thanks

alexandrevilain commented 8 months ago

Hi @bkcsfi !

The operator already provides a feature to support your use case.

On the datastore spec you can use the skipCreate field, see:

https://temporal-operator.pages.dev/api/v1beta1/#temporal.io/v1beta1.DatastoreSpec

bkcsfi commented 8 months ago

great, thank you for pointing that out. I will give that a try in the production deployment.