fix: Populate SQL_CONNECT_ATTRIBUTES in admintools and schema job
What was changed
When server.persistence.config.*.sql.connectAttributes is set, also populate the SQL_CONNECT_ATTRIBUTES env var in the temporal-schema job. According to https://github.com/temporalio/temporal/blob/main/tools/sql/handler.go#L157, the SQL_CONNECT_ATTRIBUTE env var must be in this format: key1=value1&key2=value.
Why?
If users want to use a different schema than public, they need to set the connectAttribute value to something like search_path: temporal. With this PR, the temporal-schema job will know about it and create tables in the right schema.
Checklist
-
Closes #561
-
How was this tested:
helm lint charts/temporal- Add
connectAttributesto charts/temporal/values/values.postgresql.yaml:
connectAttributes: search_path: temporal foo_bar: bazhelm template my-release charts/temporal -f charts/temporal/values/values.postgresql.yaml- Check the resulting yaml contains the
SQL_CONNECT_ATTRIBUTESenv var:- name: SQL_CONNECT_ATTRIBUTES value: "foo_bar=baz&search_path=temporal" - Run step iii against
mainand against my branch, checking the resulting yamls are the same.
@robholland, sorry for the ping! Anything I can do to help push this forward?
Please merge https://github.com/temporalio/helm-charts/tree/rh-sql-connect-attributes which contains a failing test for this, and then adjust as required.
You can run with go test -timeout 30s -run ^TestAdminToolsSqlConnectAttributes$ github.com/temporalio/helm-charts from the charts/temporal/tests directoy.
@adigiorgi-clickup ping :)
@robholland, sorry! Been super busy at work! I fixed my code and pushed it! 🙏