refresh-consumer: compare mtimes locale-independently so an unchanged secret doesn't restart its unit
`refresh_unit` read the credential file's mtime with `stat -c %.6Y | tr -d .`. coreutils prints that fraction with the locale's decimal separator, so on a host whose locale uses a comma (muede-lpt2: `1791232888,193159`) `tr` stripped nothing, the `-le` against the unit's start errored, the "unchanged" early return was skipped, and every run try-restarted the consumer. Every unit on a store-refresh timer was restarted every ~10 minutes; for `swarm-bao-ci-runner` that is `gitea-runner-swarm`, which killed every CI job running at the time. The mtime is now read with `date -r … +%s%6N`, the same digit-only format the start time already used (`date -d … +%s%6N` on systemd's fixed English timestamp), so neither side has a separator for a locale to change. A value that still does not read as digits — an unparsable start time, a missing file — now restarts nothing and logs at `err`. Skipping on doubt rather than restarting on doubt: the file's mtime is kept, so a genuinely changed credential still restarts its consumer on the first run that can read both times, whereas restarting on doubt restarts it on every run, which is this bug. Both reads also fall back to empty instead of aborting the caller's `set -e` script. `script-test-refresh-consumer` runs the rendered helper under `de_DE.UTF-8` against a stub `systemctl`, and checks first that `stat` really prints a comma there. The helper on main fails 14 of its assertions. Fixes #5230
This commit is contained in:
parent
503c8c8b3c
commit
be7eaa8181
4 changed files with 162 additions and 2 deletions
|
|
@ -55,6 +55,9 @@ in
|
|||
inherit pkgs self nixosSystem;
|
||||
inherit (pkgs) lib;
|
||||
};
|
||||
# Runs ./host-modules/lib/refresh-consumer.nix's restart decision under a
|
||||
# comma-decimal locale, against a stub `systemctl`.
|
||||
script-test-refresh-consumer = import ./script-tests/refresh-consumer.nix { inherit pkgs; };
|
||||
module-eval-nats-tls = import ./module-eval/nats-tls.nix {
|
||||
inherit pkgs self nixosSystem;
|
||||
inherit (pkgs) lib;
|
||||
|
|
|
|||
Loading…
Reference in a new issue