grafana pod: open the database the earlier container left
The pod's volume is the earlier container's data directory, and the NixOS grafana module keeps its database at `<dataDir>/data/grafana.db`. The pod set `paths.data` to the directory itself, so it opened a new, empty `grafana.db` beside the carried one, and the secret-key guard read that new file. Datasources with secrets, API tokens, hand-made dashboards, users and teams of a switched host were orphaned. `paths.data` and the guard's database path are now `<dataDir>/data`. The VM test's earlier Grafana keeps its database in the NixOS layout, and the test asserts the carried file is the only `grafana.db` in the volume. Closes #6979
This commit is contained in:
parent
42199dfa76
commit
fe6221138c
1 changed files with 41 additions and 8 deletions
|
|
@ -304,7 +304,7 @@ let
|
|||
r = rendered grafanaRemoteAuthelia;
|
||||
init = r.scripts.fetch;
|
||||
at = needle: lib.stringLength (lib.head (lib.splitString needle init));
|
||||
call = "grafana_secret_key secret/swarm/services/swarm-grafana/secret-key /legacy-secret-key/secret_key /var/lib/grafana/grafana.db openssl rand -hex 32 || exit 1";
|
||||
call = "grafana_secret_key secret/swarm/services/swarm-grafana/secret-key /legacy-secret-key/secret_key /var/lib/grafana/data/grafana.db openssl rand -hex 32 || exit 1";
|
||||
# The helper's text is part of the script: store, then file, then
|
||||
# the check of the database, then the mint.
|
||||
readStore = "bao kv get -field=value \"$leaf\"";
|
||||
|
|
@ -336,6 +336,22 @@ let
|
|||
lib.filter (lib.hasPrefix "r ") grafanaRemoteAuthelia.systemd.tmpfiles.rules
|
||||
));
|
||||
}
|
||||
{
|
||||
# The pod's volume is the earlier container's data directory, and the
|
||||
# NixOS grafana module keeps that container's database at
|
||||
# `<dataDir>/data/grafana.db`. A `paths.data` of the directory itself
|
||||
# opens a new, empty database beside it: the datasources with secrets,
|
||||
# the tokens and the dashboards made by hand are not in it. The guard
|
||||
# over the key reads the same file Grafana opens.
|
||||
name = "grafana opens the database the earlier container left, and the key's guard reads that file";
|
||||
ok =
|
||||
let
|
||||
r = rendered grafanaRemoteAuthelia;
|
||||
in
|
||||
r.settings.paths.data == "/var/lib/grafana/data"
|
||||
&& !(r.settings ? database)
|
||||
&& lib.hasInfix " ${r.settings.paths.data}/grafana.db openssl rand -hex 32" r.scripts.fetch;
|
||||
}
|
||||
{
|
||||
# swarm-controller reads alerts with this token, so the account it
|
||||
# belongs to is created and kept a Viewer, the token lands at the path
|
||||
|
|
|
|||
Loading…
Reference in a new issue