Repository navigation
Conversation
…mage
The dashboard image could only talk to PostgreSQL with sslmode=disable
in the compose setup, and verify-ca/verify-full failed against a private
CA because the datasource never got a root certificate. While testing
this, a few related problems in the datasource provisioning showed up.
TLS:
- docker-compose-dev-postgresql.yml passes GRAFANA_DATABASE_SSL_MODE
(default disable) as DATABASE_SSL_MODE, documented in env.example
- new optional DATABASE_SSL_ROOT_CERT, DATABASE_SSL_CERT and
DATABASE_SSL_KEY (file paths in the container) are written to the
datasource as sslRootCertFile/sslCertFile/sslKeyFile with
tlsConfigurationMethod=file-path; unreadable paths log a warning
Provisioning:
- the API calls use GF_SECURITY_ADMIN_USER instead of a hard-coded
"admin" and pass the credentials via --user, so a renamed admin or a
password containing characters such as @ / # no longer breaks them
- a failing curl no longer ends the entrypoint (set -e) and with it the
container; 401/403 stop the retry loop with a hint, and a final error
is logged if the datasource could not be created
- the clean slate deletes datasources by UID: Grafana 13 answers
"Not found" for deletion by numeric ID, so on every restart the old
datasource was kept ("already exists") together with its old settings
(e.g. a changed sslmode or password never took effect). Deletion by ID
is kept as a fallback for older Grafana versions
- DATASOURCE_CLEAN_SLATE=false (default true) replaces only the DevLake
datasource and keeps all other datasources, for a Grafana state that is
shared with other teams or replicas
Defaults are unchanged.
Signed-off-by: DoDiODev <DoDiDev@proton.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the dashboard image work with a managed PostgreSQL over TLS and fixes
some problems in its datasource provisioning that showed up while testing
this. Part of #9219 (section A). Defaults are unchanged.
TLS
docker-compose-dev-postgresql.ymlpassesGRAFANA_DATABASE_SSL_MODE(default
disable) to the existingDATABASE_SSL_MODE; documented inenv.example(follow-up to build(compose): make grafana port, root URL and datasource configurable #9207).DATABASE_SSL_ROOT_CERT,DATABASE_SSL_CERTandDATABASE_SSL_KEY(file paths inside the container, e.g. a mountedsecret). They are written to the datasource as
sslRootCertFile/sslCertFile/sslKeyFilewithtlsConfigurationMethod: file-path.Without them,
verify-ca/verify-fullagainst a private CA cannot work.An unreadable path logs a warning.
Datasource provisioning
GF_SECURITY_ADMIN_USER(defaultadmin) instead of ahard-coded
admin, and pass the credentials with--userinstead ofinside the URL.
Before, a renamed admin got 401 ten times and no datasource was created.
A password containing
@,/or#madecurlfail, andset -ethenended the entrypoint and with it the container (exit 6).
curlno longer ends the entrypoint. 401/403 stop the retryloop with a hint, and an
ERRORline is logged if the datasource couldnot be created. Grafana keeps running in both cases.
{"message":"Not found"}for
DELETE /api/datasources/<id>, so on every restart nothing wasdeleted, the POST hit "already exists", and the old datasource was kept
with its old settings. A changed
sslmodeor database password nevertook effect after the first start. Deletion by ID is kept as a fallback
for older Grafana versions.
DATASOURCE_CLEAN_SLATE(defaulttrue= current behaviour).falsereplaces only the DevLake datasource (by UID) and keeps all otherdatasources, for a Grafana state that is shared with other teams or
replicas. Changing the default is left to the discussion in [Feature][Grafana][config-ui] Gaps when running DevLake with a managed PostgreSQL and an external Grafana #9219.
Does this close any open issues?
Part of #9219 (section A).
Screenshots
N/A
Other Information
Tested locally with the image built from this branch and from
main(
4ad2f66df), againstpostgres:18.6withssl=onand a test CA, andmysql:8.4.11:mainsslmode=disable)verify-full+DATABASE_SSL_ROOT_CERTverify-fullwithout root cert (negative test)DATABASE_SSL_MODE=requiredisablerequireGF_SECURITY_ADMIN_USER=lakeadmin, passwordp@ss/w#rdERRORline, Grafana keeps runningDATASOURCE_CLEAN_SLATE=false+ extra datasourcebash -nandshellcheck -S warningare clean. Full CI mirror on my fork:run