Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add support for reading db connection string from a file#20910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
rowansmithau wants to merge9 commits intomain
base:main
Choose a base branch
Loading
fromrowansmithau/feat/db-read-creds-from-file

Conversation

@rowansmithau
Copy link
Contributor

@rowansmithaurowansmithau commentedNov 25, 2025
edited
Loading

This is a pr to add support for reading the db connection string from a file, which is an alternative option to reading the connection string from an environment variable.

This is the first step in addressing a lack of support for rotating db credentials, as at present a rollout restart must be performed in order for the updated credentials to be picked up by the pod, i.e. env vars are not updated in a pod when the underlying secret is updated. Apgfileurl sql driver is also added to re-read the file on each connection attempt to support credential rotation.

This would be used by populating values.yaml with:

  env:    - name: CODER_PG_CONNECTION_URL_FILE      value: "/etc/coder/pg/pg-url.txt"  volumes:    - name: coder-pg-url-file      secret:        secretName: coder-pg-url-file  volumeMounts:    - name: coder-pg-url-file      mountPath: /etc/coder/pg      readOnly: true

With it referencing a secret created using:

kubectl create secret generic coder-pg-url-file \  -n pg-coder \  --from-file=pg-url.txt=./pg-url.txtcat pg-url.txt     postgres://coder_pg:coder_pg@my-local-db-host.tld:5432/coder_pg?sslmode=require

created with mux!

@rowansmithaurowansmithau self-assigned thisNov 25, 2025
@rowansmithaurowansmithau added the helmArea: helm chart labelNov 25, 2025
@rowansmithaurowansmithauforce-pushed therowansmithau/feat/db-read-creds-from-file branch fromc6a1ee8 to14b0604CompareNovember 25, 2025 09:28
@rowansmithaurowansmithau marked this pull request as ready for reviewNovember 25, 2025 21:05
Copy link
Member

@deansheatherdeansheather left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think a fake driver is what we need but maybe@f0ssel will have more knowledge. He wrote something similar for the AWS IAM database auth system.

ifvals.PostgresURL!="" {
returnxerrors.Errorf("cannot specify both --postgres-url and --postgres-url-file")
}
postgresURL,err:=ReadPostgresURLFromFile(vals.PostgresURLFile.String())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We need some sort of go sql driver BS so we can get this to be read on every single connection attempt. Reading it once on startup won't resolve the customer's problem.

ctx,cancel:=inv.SignalNotifyContext(ctx,StopSignals...)
defercancel()

// Read the postgres URL from a file, if specified.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This code is duplicated 3 times. Maybe we should add a helper that reads both theurl andurl-file args, handles the mutual exclusion, and returns a driver string and URL string. (as well as registering the new driver).

@rowansmithaurowansmithauforce-pushed therowansmithau/feat/db-read-creds-from-file branch from9b982d9 tob9d0281CompareNovember 27, 2025 00:05
@rowansmithaurowansmithauforce-pushed therowansmithau/feat/db-read-creds-from-file branch frome0c4f0b todf7b098CompareDecember 1, 2025 00:06
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@deansheatherdeansheatherdeansheather left review comments

At least 1 approving review is required to merge this pull request.

Assignees

@rowansmithaurowansmithau

Labels

helmArea: helm chart

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@rowansmithau@deansheather

[8]ページ先頭

©2009-2025 Movatter.jp