Skip to content

Commit be1dd96

Browse files
authored
Merge pull request #5037 from input-output-hk/bench-nomad-vault
Bench nomad sub-backends
2 parents d456afb + db9a23d commit be1dd96

File tree

14 files changed

+2823
-2265
lines changed

14 files changed

+2823
-2265
lines changed

Diff for: lib.mk

+14-14
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ endif
2727
endef
2828

2929
define define_profile_targets
30-
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof), $$(prof),false, true,false,false,false, supervisor)))
31-
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-prof, $$(prof),false, true,false,false, true, supervisor)))
32-
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-auto, $$(prof),false, true, true,false,false, supervisor)))
33-
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autostay, $$(prof),false, true, true, true,false, supervisor)))
34-
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nix, $$(prof), true,false,false,false,false, supervisor)))
35-
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autonix, $$(prof), true,false, true,false,false, supervisor)))
36-
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomad, $$(prof), true,false,false,false,false, nomad)))
37-
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomad-auto, $$(prof), true,false, true,false,false, nomad)))
38-
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadpodman, $$(prof), true,false,false,false,false, nomadpodman)))
39-
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadpodman-auto, $$(prof), true,false, true,false,false, nomadpodman)))
40-
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadexec, $$(prof), true,false,false,false,false, nomadexec)))
41-
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadexec-auto, $$(prof), true,false, true,false,false, nomadexec)))
42-
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nixops, $$(prof), true, true,false,false,false, nixops)))
43-
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autonixops, $$(prof), true, true, true, true,false, nixops)))
30+
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof), $$(prof),false, true,false,false,false,supervisor)))
31+
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-prof, $$(prof),false, true,false,false, true,supervisor)))
32+
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-auto, $$(prof),false, true, true,false,false,supervisor)))
33+
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autostay, $$(prof),false, true, true, true,false,supervisor)))
34+
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nix, $$(prof), true,false,false,false,false,supervisor)))
35+
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autonix, $$(prof), true,false, true,false,false,supervisor)))
36+
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadcloud, $$(prof), true,false,false,false,false,nomadcloud)))
37+
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadcloud-auto, $$(prof), true,false, true,false,false,nomadcloud)))
38+
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadexec, $$(prof), true,false,false,false,false,nomadexec)))
39+
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadexec-auto, $$(prof), true,false, true,false,false,nomadexec)))
40+
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadpodman, $$(prof), true,false,false,false,false,nomadpodman)))
41+
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nomadpodman-auto,$$(prof), true,false, true,false,false,nomadpodman)))
42+
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-nixops, $$(prof), true, true,false,false,false,nixops)))
43+
$$(foreach prof,$(1),$$(eval $$(call proftgt,$$(prof)-autonixops, $$(prof), true, true, true, true,false,nixops)))
4444
endef

Diff for: nix/pkgs.nix

+10-10
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ let
1919
let
2020
backendRegistry =
2121
{
22-
nixops = params:
23-
import ./workbench/backend/nixops.nix params;
24-
nomad = params:
25-
import ./workbench/backend/nomad.nix (params // {execTaskDriver=false;});
26-
nomadexec = params:
27-
import ./workbench/backend/nomad.nix (params // {execTaskDriver=true; });
28-
nomadpodman = params:
29-
import ./workbench/backend/nomad.nix (params // {execTaskDriver=false;});
30-
supervisor = params:
31-
import ./workbench/backend/supervisor.nix params;
22+
nixops = params:
23+
import ./workbench/backend/nixops.nix params;
24+
nomadcloud = params:
25+
import ./workbench/backend/nomad/cloud.nix params;
26+
nomadexec = params:
27+
import ./workbench/backend/nomad/exec.nix params;
28+
nomadpodman = params:
29+
import ./workbench/backend/nomad/podman.nix params;
30+
supervisor = params:
31+
import ./workbench/backend/supervisor.nix params;
3232
}
3333
;
3434
in

Diff for: nix/workbench/backend/nomad.nix

+4-108
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,21 @@
11
{ pkgs
22
, lib
33
, stateDir
4-
, basePort
5-
## `useCabalRun` not used here unlike `supervisor.nix`.
64
# TODO: Fetch this from config services inside materialise-profile !
75
, eventlogged ? true
8-
# The exec driver uses SRE's plugin that allows Nix derivation artifacts!
9-
, execTaskDriver
106
, ...
117
}:
128
let
139

14-
name = "nomad";
15-
16-
# Unlike the supervisor backend `useCabalRun` is always false here.
17-
useCabalRun = false;
18-
19-
# The versions of Nomad and the Nomad plugins needed are defined here instead
20-
# of inside the flake!
21-
extraShellPkgs = let
22-
nomad = (pkgs.buildGo119Module rec {
23-
pname = "nomad";
24-
version = "1.4.3"; # Both Nomad versions are using 1.4.3
25-
subPackages = [ "." ];
26-
doCheck = true;
27-
src = pkgs.fetchFromGitHub {
28-
owner = "hashicorp";
29-
repo = pname;
30-
rev = "v${version}";
31-
# nix-prefetch-url --unpack https://github.com/hashicorp/nomad/archive/v1.4.3.tar.gz
32-
sha256 = "0j2ik501sg6diyabwwfrqnz1wxx485w5pxry4bfkg5smgyp5y18r";
33-
};
34-
# error: either `vendorHash` or `vendorSha256` is required
35-
# https://discourse.nixos.org/t/buildgomodule-how-to-get-vendorsha256/9317
36-
vendorSha256 = "sha256-JQRpsQhq5r/QcgFwtnptmvnjBEhdCFrXFrTKkJioL3A=";
37-
});
38-
# Both Nomad source versions are using 1.4.3 but this one returns:
39-
# > nomad --version
40-
# Nomad v1.4.4-dev
41-
nomad-sre = (pkgs.buildGo119Module rec {
42-
pname = "nomad";
43-
version = "1.4.3";
44-
subPackages = [ "." ];
45-
doCheck = true;
46-
src = pkgs.fetchFromGitHub { # "github:input-output-hk/nomad/release/1.4.3"
47-
owner = "input-output-hk";
48-
repo = pname;
49-
rev = "2b8a93390"; # Use to be "release/${version}" but it changes.
50-
# nix-prefetch-url --unpack https://github.com/input-output-hk/nomad/archive/2b8a93390/1.4.3.tar.gz
51-
sha256 = "0l2sfhpg0p5mjdbipib7q63wlsrczr2fkq9xi641vhgxsjmprvwm";
52-
};
53-
# error: either `vendorHash` or `vendorSha256` is required
54-
# https://discourse.nixos.org/t/buildgomodule-how-to-get-vendorsha256/9317
55-
vendorSha256 = "sha256-JQRpsQhq5r/QcgFwtnptmvnjBEhdCFrXFrTKkJioL3A=";
56-
});
57-
# This plugin is defined but only used if `execTaskDriver` is false.
58-
nomad-driver-podman = (pkgs.buildGo119Module rec {
59-
pname = "nomad-driver-podman";
60-
version = "0.4.1";
61-
subPackages = [ "." ];
62-
doCheck = false; # some tests require a running podman service to pass
63-
src = pkgs.fetchFromGitHub {
64-
owner = "hashicorp";
65-
repo = pname;
66-
rev = "v${version}";
67-
# nix-prefetch-url --unpack https://github.com/hashicorp/nomad-driver-podman/archive/v0.4.1.tar.gz
68-
sha256 = "03856ws02xkqg5374x35zzz5900456rvpsridsjgwvvyqnysn9ls";
69-
};
70-
# error: either `vendorHash` or `vendorSha256` is required
71-
# https://discourse.nixos.org/t/buildgomodule-how-to-get-vendorsha256/9317
72-
vendorSha256 = "sha256-AtgxHAkNzzjMQoSqROpuNoSDum/6JR+mLpcHLFL9EIY=";
73-
});
74-
in
75-
(if !execTaskDriver
76-
then [ nomad pkgs.podman nomad-driver-podman ]
77-
# If we are going to use the `exec` driver we use the SRE patched
78-
# version of Nomad that allows to use `nix_installables` as artifacts.
79-
else [ nomad-sre ]
80-
)
81-
++
82-
[
83-
# Network tools to be able to use bridge networking and the HTTP server
84-
# to upload/download the genesis tar file.
85-
pkgs.cni-plugins pkgs.webfs
86-
# Amazon S3 HTTP to upload the genesis.
87-
pkgs.awscli
88-
]
89-
;
90-
9110
# Backend-specific Nix bits:
9211
materialise-profile =
9312
{ profileNix }:
9413
let
9514
supervisorConf = import ./supervisor-conf.nix
9615
{ inherit profileNix;
9716
inherit pkgs lib stateDir;
98-
unixHttpServerPort = if execTaskDriver
99-
# ''{{ env "NOMAD_TASK_DIR" }}/supervisor.sock''
100-
then "/tmp/supervisor.sock" # TODO: Is this OK?
101-
else "/tmp/supervisor.sock"
102-
;
17+
# ''{{ env "NOMAD_TASK_DIR" }}/supervisor.sock''
18+
unixHttpServerPort = "/tmp/supervisor.sock";
10319
}
10420
;
10521
# Intermediate / workbench-adhoc container specifications
@@ -241,7 +157,7 @@ let
241157
};
242158
};
243159
};
244-
in pkgs.runCommand "workbench-backend-output-${profileNix.profileName}-${name}"
160+
in pkgs.runCommand "workbench-backend-output-${profileNix.profileName}-nomad"
245161
({
246162
containerSpecsJSON = pkgs.writeText "workbench-cluster-container-pkgs.json"
247163
(lib.generators.toJSON {} containerSpecs);
@@ -251,24 +167,4 @@ let
251167
ln -s $containerSpecsJSON $out/container-specs.json
252168
'';
253169

254-
overlay =
255-
proTopo: self: super:
256-
{
257-
};
258-
259-
service-modules = {
260-
node = { config, ... }:
261-
let selfCfg = config.services.cardano-node;
262-
i = toString selfCfg.nodeId;
263-
in {
264-
services.cardano-node.stateDir = stateDir + "/node-${i}";
265-
}
266-
;
267-
};
268-
269-
in
270-
{
271-
name = "nomad";
272-
273-
inherit extraShellPkgs materialise-profile overlay stateDir basePort useCabalRun service-modules;
274-
}
170+
in { inherit materialise-profile; }

0 commit comments

Comments
 (0)