hive-matrix: the fallocate probe works inside tuwunel's sandbox
Refs #6885
This commit is contained in:
parent
8f7c45d40f
commit
05e59c1e8c
1 changed files with 181 additions and 28 deletions
|
|
@ -158,24 +158,9 @@ let
|
|||
# the database directory under /var/lib.
|
||||
stateName = "tuwunel";
|
||||
|
||||
# tuwunel's `rocksdb_allow_fallocate` is off only where its database sits on
|
||||
# a filesystem that cannot honour RocksDB's log preallocation. A swarm's
|
||||
# filesystem is not known at evaluation, so the unit's `ExecStartPre` reads
|
||||
# it at each start, from the same superblock magics tuwunel itself tests for
|
||||
# its warning (btrfs `9123683e`, ZFS `2fc12fc1`), and writes the override
|
||||
# to an environment file. tuwunel applies `TUWUNEL_*` variables over its
|
||||
# config file. Anywhere else, or if `stat` fails, the file is empty and the
|
||||
# default (`true`) stands.
|
||||
tuwunelRuntimeDir = "/run/tuwunel";
|
||||
fallocateEnvFile = "${tuwunelRuntimeDir}/fallocate.env";
|
||||
fallocateProbe = pkgs.writeShellScript "tuwunel-fallocate-probe" ''
|
||||
set -u
|
||||
: > ${fallocateEnvFile}
|
||||
magic=$(${pkgs.coreutils}/bin/stat -f -c %t /var/lib/${stateName}) || exit 0
|
||||
case "$magic" in
|
||||
9123683e | 2fc12fc1) echo TUWUNEL_ROCKSDB_ALLOW_FALLOCATE=false > ${fallocateEnvFile} ;;
|
||||
esac
|
||||
'';
|
||||
# `rocksdb_allow_fallocate` is off only where the database is on btrfs or ZFS:
|
||||
# a probe at each start decides, see the file.
|
||||
fallocateProbe = import ./lib/tuwunel-fallocate-probe.nix { inherit pkgs; };
|
||||
|
||||
# ── the swarm's own appservice ──────────────────────────────────────
|
||||
#
|
||||
|
|
@ -1117,11 +1102,11 @@ in
|
|||
# Upstream's `ProtectSystem = "strict"` leaves `/run` read-only.
|
||||
systemd.services.tuwunel.serviceConfig.ReadWritePaths = [ socketDir ];
|
||||
|
||||
# The `RuntimeDirectory` is upstream's. The file is read before each
|
||||
# command of the unit runs, so `ExecStartPre` writes what `ExecStart`
|
||||
# sees; the `-` keeps a missing file from failing the start.
|
||||
systemd.services.tuwunel.serviceConfig.ExecStartPre = [ fallocateProbe ];
|
||||
systemd.services.tuwunel.serviceConfig.EnvironmentFile = [ "-${fallocateEnvFile}" ];
|
||||
# The probe's file lives in upstream's `RuntimeDirectory`.
|
||||
systemd.services.tuwunel.serviceConfig.ExecStartPre =
|
||||
(fallocateProbe.serviceConfig "/var/lib/${stateName}").ExecStartPre;
|
||||
systemd.services.tuwunel.serviceConfig.EnvironmentFile =
|
||||
(fallocateProbe.serviceConfig "/var/lib/${stateName}").EnvironmentFile;
|
||||
|
||||
# Keeps DynamicUser=true + PrivateUsers=true intact — no
|
||||
# host-side chown :tuwunel / GID-pin gymnastics needed.
|
||||
|
|
|
|||
Loading…
Reference in a new issue