mattermost / mattermost-operator

Mattermost Operator for Kubernetes
Apache License 2.0
119 stars 73 forks source link

Postgres connection string invalid control character in URL for secret data in base64 #342

Open jpnorenam opened 1 year ago

jpnorenam commented 1 year ago

Summary

In Kubernetes v1.26, the secret data can't be created as plain text

Error from server (BadRequest): error when creating "STDIN": Secret in version "v1" cannot be handled as a Secret: illegal base64 data at input byte <n>

And in base64, as the documentation suggests

apiVersion: v1
data:
  DB_CONNECTION_CHECK_URL: cG9zdGdyZXM6Ly91c2VyOnN1cGVyX3NlY3JldF9wYXNzd29yZEBteS1kYXRhYmFzZS5jbHVzdGVyLWFiY2QudXMtZWFzdC0xLnJkcy5hbWF6b25hd3MuY29tOjU0MzIvbWF0dGVybW9zdD9jb25uZWN0X3RpbWVvdXQ9MTAK
  DB_CONNECTION_STRING: cG9zdGdyZXM6Ly91c2VyOnN1cGVyX3NlY3JldF9wYXNzd29yZEBteS1kYXRhYmFzZS5jbHVzdGVyLWFiY2QudXMtZWFzdC0xLnJkcy5hbWF6b25hd3MuY29tOjU0MzIvbWF0dGVybW9zdD9jb25uZWN0X3RpbWVvdXQ9MTAK
  MM_SQLSETTINGS_DATASOURCEREPLICAS: cG9zdGdyZXM6Ly91c2VyOnN1cGVyX3NlY3JldF9wYXNzd29yZEBteS1kYXRhYmFzZS5jbHVzdGVyLXJvLWFiY2QudXMtZWFzdC0xLnJkcy5hbWF6b25hd3MuY29tOjU0MzIvbWF0dGVybW9zdD9jb25uZWN0X3RpbWVvdXQ9MTAK
kind: Secret
metadata:
  name: my-postgres-connection
type: Opaque

the operator seems to add a '/n' at the end of the connection string, resulting in the following error

Defaulted container "mattermost" out of: mattermost, init-check-database (init)
Error: failed to load configuration: failed to initialize: failed to create Configurations table: parse "postgres://user:super_secret_password@my-database.cluster-abcd.us-east-1.rds.amazonaws.com:5432/mattermost?connect_timeout=10\n": net/url: invalid control character in URL
Szymongib commented 1 year ago

FYI https://github.com/mattermost/mattermost-operator/issues/269#issuecomment-1432775722