diff options
| author | tv <tv@krebsco.de> | 2026-11-12 02:33:43 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-12 02:33:43 +0000 |
| commit | 55f41b5f04efee81b4ab48899214bc59448af325 (patch) | |
| tree | 766b55c36b2bd0dab23963eacc352327f1be2504 /pkgs/populate/default.nix | |
| parent | 84444c00bf5ad06f8bca4e4cd68e6d227a8efd1e (diff) | |
populate: stop the ssh master also after failures
Populate stopped the ssh master at the end of its script, which a failure
skips. The master then stays for an hour, with its control socket gone
along with populate's temporary directory. Populate stops it on exit
now, before removing that directory.
An edge case checks that no master remains after a failing and after a
succeeding deploy.
Diffstat (limited to 'pkgs/populate/default.nix')
| -rw-r--r-- | pkgs/populate/default.nix | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/pkgs/populate/default.nix b/pkgs/populate/default.nix index 75fbf61..7a52ca9 100644 --- a/pkgs/populate/default.nix +++ b/pkgs/populate/default.nix @@ -867,7 +867,14 @@ writers.writeDash "populate.${target.host}" '' TMPDIR=$(${coreutils}/bin/mktemp -dt populate.XXXXXXXX) readonly TMPDIR # Ensure the trap will delete the correct thing. export TMPDIR # Share it with the jobs and the ssh wrapper. - trap 'rm -R "$TMPDIR"' EXIT + # Stops the ssh master, if any source started one, also after failures, + # before its control socket goes away with $TMPDIR. + stop_ssh_master() { + if ${ssh' target} -q -O check ${quote target.host} 2>/dev/null; then + ${ssh' target} -q -O stop ${quote target.host} + fi + } + trap 'stop_ssh_master; rm -R "$TMPDIR"' EXIT ${check { inherit force target; }} set -x @@ -876,8 +883,4 @@ writers.writeDash "populate.${target.host}" '' ${flakes target source} ${optionalString prune (prune' target source)} - # Stop the ssh master, if any source started one. - if ${ssh' target} -q -O check ${quote target.host} 2>/dev/null; then - ${ssh' target} -q -O stop ${quote target.host} - fi '' |
