Skip to content

Commit

Permalink
fixed issue by adding lingering to stop rootless user being killed
Browse files Browse the repository at this point in the history
Signed-off-by: Robbie Buxton <[email protected]>
  • Loading branch information
RobbieBuxton authored and elpdt852 committed Oct 22, 2024
1 parent cb70837 commit f295782
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
1 change: 1 addition & 0 deletions modules/nixos/tests/gvisor.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ in {
users.users.alice = {
uid = 1000;
isNormalUser = true;
linger = true;
};

environment.variables = {
Expand Down
1 change: 1 addition & 0 deletions modules/nixos/tests/k3s-rootless.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
users.users.alice = {
uid = 1000;
isNormalUser = true;
linger = true;
};
};

Expand Down
1 change: 1 addition & 0 deletions modules/nixos/tests/push-n-pull.nix
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ in {
users.users.alice = {
uid = 1000;
isNormalUser = true;
linger = true;
};

environment.variables = {
Expand Down
16 changes: 3 additions & 13 deletions modules/nixos/tests/snapshotter.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ config, pkgs, lib, ... }:
let
helloDrvFile = pkgs.nix-snapshotter.buildImage {
name = "ghcr.io/pdtpartners/hello-world";
name = "ghcr.io/nix-snapshotter/hello-world";
tag = "latest";
config.entrypoint = [
(pkgs.writeShellScript "hello-world" ''
Expand Down Expand Up @@ -88,6 +88,7 @@ in {
users.users.alice = {
uid = 1000;
isNormalUser = true;
linger = true;
};

environment.variables = {
Expand Down Expand Up @@ -120,30 +121,19 @@ in {
];

in ''
def collect_coverage(machine):
coverfiles = machine.succeed("ls /tmp/go-cover").split()
for coverfile in coverfiles:
machine.copy_from_vm(f"/tmp/go-cover/{coverfile}", f"build/go-cover/${config.name}-{machine.name}")
def wait_for_unit(machine, service, user = "alice"):
if "rootless" in machine.name:
machine.wait_until_succeeds(f"systemctl --user --machine={user}@ is-active {service}")
else:
machine.wait_for_unit(service)
def stop_unit(machine, service, user = "alice"):
if "rootless" in machine.name:
machine.succeed(f"systemctl --user --machine={user}@ stop {service}")
else:
machine.succeed(f"systemctl stop {service}")
def test(machine, sudo_su = ""):
wait_for_unit(machine, "nix-snapshotter.service")
wait_for_unit(machine, "containerd.service")
wait_for_unit(machine, "preload-containerd.service")
with subtest(f"{machine.name}: Run container with an executable outPath"):
out = machine.succeed(f"{sudo_su} nerdctl run --rm ghcr.io/pdtpartners/hello-world")
out = machine.succeed(f"{sudo_su} nerdctl run ghcr.io/nix-snapshotter/hello-world")
assert "Hello, world!" in out
with subtest(f"{machine.name}: Run container with CNI built with pkgs.dockerTools.buildImage"):
Expand Down

0 comments on commit f295782

Please sign in to comment.