Compare commits
7 commits
nixos-stop
...
main
Author | SHA1 | Date | |
---|---|---|---|
ec4f2a836d | |||
|
90bc855327 | ||
|
16c4d4d8b8 | ||
|
236f9dd82d | ||
|
ab9bdaf08f | ||
|
555e7ba634 | ||
|
7e7aa3dfc6 |
7 changed files with 29 additions and 96 deletions
18
flake.lock
generated
18
flake.lock
generated
|
@ -7,11 +7,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1717285511,
|
"lastModified": 1722555600,
|
||||||
"narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=",
|
"narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=",
|
||||||
"owner": "hercules-ci",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-parts",
|
"repo": "flake-parts",
|
||||||
"rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8",
|
"rev": "8471fe90ad337a8074e957b69ca4d0089218391d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -64,11 +64,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1713898448,
|
"lastModified": 1719226092,
|
||||||
"narHash": "sha256-6q6ojsp/Z9P2goqnxyfCSzFOD92T3Uobmj8oVAicUOs=",
|
"narHash": "sha256-YNkUMcCUCpnULp40g+svYsaH1RbSEj6s4WdZY/SHe38=",
|
||||||
"owner": "hercules-ci",
|
"owner": "hercules-ci",
|
||||||
"repo": "hercules-ci-effects",
|
"repo": "hercules-ci-effects",
|
||||||
"rev": "c0302ec12d569532a6b6bd218f698bc402e93adc",
|
"rev": "11e4b8dc112e2f485d7c97e1cee77f9958f498f5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -79,11 +79,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1717196966,
|
"lastModified": 1722630782,
|
||||||
"narHash": "sha256-yZKhxVIKd2lsbOqYd5iDoUIwsRZFqE87smE2Vzf6Ck0=",
|
"narHash": "sha256-hMyG9/WlUi0Ho9VkRrrez7SeNlDzLxalm9FwY7n/Noo=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "57610d2f8f0937f39dbd72251e9614b1561942d8",
|
"rev": "d04953086551086b44b6f3c6b7eeb26294f207da",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -86,12 +86,6 @@
|
||||||
flake = {
|
flake = {
|
||||||
debug = { inherit inputs config lib; };
|
debug = { inherit inputs config lib; };
|
||||||
|
|
||||||
defaultPackage =
|
|
||||||
lib.mapAttrs
|
|
||||||
(_system: ps: lib.warn "arion.defaultPackage has been removed in favor of arion.packages.\${system}.default"
|
|
||||||
ps.default)
|
|
||||||
config.flake.packages;
|
|
||||||
|
|
||||||
lib = {
|
lib = {
|
||||||
eval = import ./src/nix/eval-composition.nix;
|
eval = import ./src/nix/eval-composition.nix;
|
||||||
build = args@{ ... }:
|
build = args@{ ... }:
|
||||||
|
|
|
@ -42,22 +42,10 @@ let
|
||||||
cfg.docker.client.package
|
cfg.docker.client.package
|
||||||
];
|
];
|
||||||
environment.ARION_PREBUILT = config.settings.out.dockerComposeYaml;
|
environment.ARION_PREBUILT = config.settings.out.dockerComposeYaml;
|
||||||
serviceConfig.Type = "oneshot";
|
script = ''
|
||||||
serviceConfig.RemainAfterExit = true;
|
echo 1>&2 "docker compose file: $ARION_PREBUILT"
|
||||||
serviceConfig.ExecStart = [
|
arion --prebuilt-file "$ARION_PREBUILT" up
|
||||||
(lib.getExe (pkgs.writeScriptBin "nixos-arion-start" ''
|
'';
|
||||||
#!${pkgs.runtimeShell}
|
|
||||||
echo 1>&2 "starting arion project: $ARION_PREBUILT"
|
|
||||||
arion --prebuilt-file "$ARION_PREBUILT" up --detach
|
|
||||||
''))
|
|
||||||
];
|
|
||||||
serviceConfig.ExecStop = [
|
|
||||||
(lib.getExe (pkgs.writeScriptBin "nixos-arion-stop" ''
|
|
||||||
#!${pkgs.runtimeShell}
|
|
||||||
echo 1>&2 "stopping arion project: $ARION_PREBUILT"
|
|
||||||
arion --prebuilt-file "$ARION_PREBUILT" down
|
|
||||||
''))
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -210,6 +210,11 @@ in
|
||||||
default = [];
|
default = [];
|
||||||
description = serviceRef "external_links";
|
description = serviceRef "external_links";
|
||||||
};
|
};
|
||||||
|
service.profiles = mkOption {
|
||||||
|
type = listOf str;
|
||||||
|
default = [];
|
||||||
|
description = serviceRef "profiles";
|
||||||
|
};
|
||||||
service.extra_hosts = mkOption {
|
service.extra_hosts = mkOption {
|
||||||
type = listOf str;
|
type = listOf str;
|
||||||
default = [];
|
default = [];
|
||||||
|
@ -411,5 +416,7 @@ in
|
||||||
inherit (config.service) working_dir;
|
inherit (config.service) working_dir;
|
||||||
} // lib.optionalAttrs (config.service.user != null) {
|
} // lib.optionalAttrs (config.service.user != null) {
|
||||||
inherit (config.service) user;
|
inherit (config.service) user;
|
||||||
|
} // lib.optionalAttrs (config.service.profiles != []) {
|
||||||
|
inherit (config.service) profiles;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
# Currently broken; kafka can't reach zookeeper
|
# Currently broken; kafka can't reach zookeeper
|
||||||
nixosModuleWithPodman =
|
# nixosModuleWithPodman =
|
||||||
import ./nixos-virtualization-arion-test/test.nix final {
|
# import ./nixos-virtualization-arion-test/test.nix final {
|
||||||
virtualisation.arion.backend = "podman-socket";
|
# virtualisation.arion.backend = "podman-socket";
|
||||||
};
|
# };
|
||||||
|
|
||||||
testWithPodman =
|
testWithPodman =
|
||||||
nixosTest (import ./arion-test { usePodman = true; pkgs = final; });
|
nixosTest (import ./arion-test { usePodman = true; pkgs = final; });
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, pkgs, ... }: {
|
{ pkgs, ... }: {
|
||||||
project.name = "whale";
|
project.name = "whale";
|
||||||
|
|
||||||
docker-compose.raw = {
|
docker-compose.raw = {
|
||||||
|
@ -59,28 +59,4 @@
|
||||||
"start-foreground"
|
"start-foreground"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
services.stop-probe = {
|
|
||||||
image.command = [
|
|
||||||
(lib.getExe (pkgs.writeScriptBin "stop-probe" ''
|
|
||||||
#!${pkgs.runtimeShell}
|
|
||||||
touch /diagnostics/stop-probe-started
|
|
||||||
onSIGTERM() {
|
|
||||||
echo "Handling SIGTERM"
|
|
||||||
touch /diagnostics/stop-probe-terminated-cleanly
|
|
||||||
echo "Bye!"
|
|
||||||
}
|
|
||||||
echo "Registering SIGTERM handler"
|
|
||||||
trap onSIGTERM SIGTERM
|
|
||||||
sleep 3600
|
|
||||||
''))
|
|
||||||
];
|
|
||||||
service.useHostStore = true;
|
|
||||||
service.volumes = [
|
|
||||||
"/tmp/shared:/diagnostics"
|
|
||||||
];
|
|
||||||
service.environment = {
|
|
||||||
"PATH" = lib.makeBinPath [ pkgs.busybox ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
pkgs: module:
|
pkgs: module:
|
||||||
|
|
||||||
pkgs.testers.runNixOSTest ({ lib, ... }:{
|
pkgs.nixosTest {
|
||||||
name = "test-basic-arion-kafka";
|
name = "test-basic-arion-kafka";
|
||||||
nodes = {
|
nodes = {
|
||||||
machine = { ... }: {
|
machine = { ... }: {
|
||||||
|
@ -16,13 +16,10 @@ pkgs.testers.runNixOSTest ({ lib, ... }:{
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
testScript = { nodes, ... }: ''
|
testScript = ''
|
||||||
machine.wait_for_unit("sockets.target")
|
machine.wait_for_unit("sockets.target")
|
||||||
machine.wait_for_unit("arion-whale.service")
|
machine.wait_for_unit("arion-whale.service")
|
||||||
|
|
||||||
${# TODO: make the kafka service work on podman-socket; some networking issue
|
|
||||||
lib.optionalString (nodes.machine.virtualisation.arion.backend != "podman-socket") ''
|
|
||||||
|
|
||||||
machine.succeed("""
|
machine.succeed("""
|
||||||
(echo "hello"; echo "world") \
|
(echo "hello"; echo "world") \
|
||||||
| ${pkgs.apacheKafka}/bin/kafka-console-producer.sh \
|
| ${pkgs.apacheKafka}/bin/kafka-console-producer.sh \
|
||||||
|
@ -39,34 +36,5 @@ pkgs.testers.runNixOSTest ({ lib, ... }:{
|
||||||
) 2>/dev/console
|
) 2>/dev/console
|
||||||
""")
|
""")
|
||||||
|
|
||||||
# make sure logs were captured
|
|
||||||
machine.succeed("""
|
|
||||||
# Check that messages were logged with field "CONTAINER_NAME" set to "whale-zookeeper-1"
|
|
||||||
journalctl --output json | ${pkgs.jq}/bin/jq 'select(.CONTAINER_NAME=="whale-zookeeper-1") | .MESSAGE' | grep -F 'org.apache.zookeeper'
|
|
||||||
""")
|
|
||||||
|
|
||||||
''}
|
|
||||||
|
|
||||||
machine.wait_until_succeeds("""
|
|
||||||
journalctl --grep 'Registering SIGTERM handler' >/dev/null
|
|
||||||
""")
|
|
||||||
|
|
||||||
# explore the shared mounts, as they're undocumented
|
|
||||||
machine.succeed("""
|
|
||||||
mount >&2
|
|
||||||
touch /tmp/xchg/this-is-xchg
|
|
||||||
touch /tmp/shared/this-is-shared
|
|
||||||
""")
|
|
||||||
|
|
||||||
machine.shutdown()
|
|
||||||
|
|
||||||
# show what's in machine.shared_dir by running `ls` on the host
|
|
||||||
dir = machine.shared_dir
|
|
||||||
import os
|
|
||||||
print(f'Contents of {dir}:')
|
|
||||||
os.system(f'ls -l {dir}')
|
|
||||||
# dir/stop-probe-terminated-cleanly must exist
|
|
||||||
assert os.path.exists(f'{dir}/stop-probe-terminated-cleanly'), f'{dir}/stop-probe-terminated-cleanly does not exist'
|
|
||||||
|
|
||||||
'';
|
'';
|
||||||
})
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue