Compare commits

..
Author SHA1 Message Date
4e73ec02c8 fix: sporadic socat kill errors in the EXIT trap
Some checks failed
CI / check (push) Has been cancelled
basically, the tests sporadically fail to kill the `socat` process,
reporting it to not exist. in the log, you could also see the `socat`
existing with SIG15. so my guess is -- `socat` can get killed by the
environment (nix build pipeline, for instance), and would no longer
require a cleanup (won't be reparented to PID1).

so the mental shift is -- as long as `socat` is gone, the clean was
successful. the failure mode here would be incorrectly capturing
`socat`'s PID, or missing the `kill` command (right now, it comes from
`coreutils` package, so presumably it would always be available).
2026-05-21 18:19:07 +01:00
c3cf0f67ee fix: correctly forward the cli args 2026-05-21 17:47:45 +01:00
2 changed files with 26 additions and 4 deletions

View file

@ -62,7 +62,7 @@
export HTTPS_PROXY=http://127.0.0.1:7000 export HTTPS_PROXY=http://127.0.0.1:7000
export NO_PROXY=localhost,127.0.0.1 export NO_PROXY=localhost,127.0.0.1
trap "${pkgs.coreutils}/bin/kill $HTTP_SOCAT_PID" EXIT trap "${pkgs.coreutils}/bin/kill $HTTP_SOCAT_PID || true" EXIT
${command pkgs} "$@" ${command pkgs} "$@"
''; '';
@ -145,14 +145,14 @@
${pkgs.socat}/bin/socat UNIX-LISTEN:"$JD/net.sock",fork TCP:127.0.0.1:"$FREE_PORT" &>/dev/null & ${pkgs.socat}/bin/socat UNIX-LISTEN:"$JD/net.sock",fork TCP:127.0.0.1:"$FREE_PORT" &>/dev/null &
SOCAT_PID=$! SOCAT_PID=$!
trap "${pkgs.coreutils}/bin/rm -rf $JD; ${pkgs.coreutils}/bin/kill $PROXY_PID $SOCAT_PID" EXIT trap "${pkgs.coreutils}/bin/rm -rf $JD; ${pkgs.coreutils}/bin/kill $PROXY_PID $SOCAT_PID || true" EXIT
export NIX_CONFIG=" export NIX_CONFIG="
''${NIX_CONFIG:-} ''${NIX_CONFIG:-}
extra-experimental-features = nix-command flakes extra-experimental-features = nix-command flakes
substitute = true" substitute = true"
${jailed}/bin/unsafe-cell ${jailed}/bin/unsafe-cell "$@"
''; '';
in in
host-script host-script

View file

@ -19,6 +19,7 @@ nixpkgs.lib.genAttrs
logDir ? "$JD", logDir ? "$JD",
worktreePath, worktreePath,
nixDaemonSocket ? "/var/nix/daemon-socket", nixDaemonSocket ? "/var/nix/daemon-socket",
extraArgs ? "",
}: }:
let let
cell = unsafe-cell.lib.mkCell.${system} { cell = unsafe-cell.lib.mkCell.${system} {
@ -38,7 +39,7 @@ nixpkgs.lib.genAttrs
export HOME=$(pwd) export HOME=$(pwd)
export LANG=C export LANG=C
mkdir ./cell mkdir ./cell
${cell} ${cell} ${extraArgs}
touch $out touch $out
echo ":: test passed: ${name}" echo ":: test passed: ${name}"
''; '';
@ -379,6 +380,27 @@ nixpkgs.lib.genAttrs
echo "ok 1 - extra combinator env var propagated" echo "ok 1 - extra combinator env var propagated"
''; '';
}; };
# CLI arguments forwarded into the jail
cli-args = mkJailTest "cli-args" {
worktreePath = "./cell";
extraArgs = "foo bar baz";
command =
pkgs:
pkgs.writeScript "cli-args" ''
set -euo pipefail
[ "$1" = "foo" ]
echo "ok 2 - first arg is foo"
[ "$2" = "bar" ]
echo "ok 3 - second arg is bar"
[ "$3" = "baz" ]
echo "ok 4 - third arg is baz"
echo "PASS: CLI arguments forwarded correctly"
'';
};
}; };
allTests = builtins.attrValues tests; allTests = builtins.attrValues tests;