Skip to content

Commit

Permalink
Merge pull request #4995 from input-output-hk/bench-nomad-genesis
Browse files Browse the repository at this point in the history
workbench: Distribute genesis using an intermediate storage service
  • Loading branch information
deepfire authored Mar 27, 2023
2 parents e650247 + e1f7d47 commit aa7f365
Show file tree
Hide file tree
Showing 6 changed files with 278 additions and 173 deletions.
1 change: 1 addition & 0 deletions nix/workbench/backend/backend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ case "${op}" in
setenv-defaults ) backend_$WB_BACKEND "$@";;
allocate-run ) backend_$WB_BACKEND "$@";;
describe-run ) backend_$WB_BACKEND "$@";;
deploy-genesis ) backend_$WB_BACKEND "$@";;
start ) backend_$WB_BACKEND "$@";;
start-nodes ) backend_$WB_BACKEND "$@";;
start-node ) backend_$WB_BACKEND "$@";;
Expand Down
51 changes: 0 additions & 51 deletions nix/workbench/backend/nomad-job.nix
Original file line number Diff line number Diff line change
Expand Up @@ -81,46 +81,6 @@ let
cd "''${TASK_WORKDIR}"
fi
# If the "genesis" directory already exists, Nomad or Podman have
# created it or mounted it. Do nothing with it!
if ! test -d /local/run/current/genesis
then
# Check if a Nomad "artifact" was downloaded and create the folder!
# Until this Nomad PR is merged and released, Nomad extracts
# artifacts setting files ownerships to the user running the
# Nomad client. So, for example, I'm running the Nomad client as
# root to be able to used the exec drivers but as processes are
# run as "nobody:nogoup" / "65534:65534" inside the chroot cardano-node
# exists with error "permission denied"!
# https://github.com/hashicorp/nomad/pull/13755
# https://github.com/hashicorp/nomad/issues/5020
if test -f /local/run/current/genesis.tar.zst
then
${coreutils}/bin/mkdir -p /local/run/current/genesis
PATH="''${PATH}:${zstd}/bin"; \
${gnutar}/bin/tar --extract --zstd \
--file=/local/run/current/genesis.tar.zst \
--one-top-level=/local/run/current/genesis \
--same-permissions \
--no-same-owner \
--numeric-owner \
--owner="$(${coreutils}/bin/id --user)" \
--group="$(${coreutils}/bin/id --group)"
else
if ! test "''${NOMAD_TASK_NAME}" = "tracer"
then
echo "ERROR: No genesis folder and no genesis tar.zst file"
echo "ls -la /local/run/current/:"
${coreutils}/bin/ls -la /local/run/current/
exit 1
else
echo "Running \"tracer\", no genesis folder is needed!"
fi
fi
else
echo "INFO: The genesis folder exists, the workbench must have taken care of this!"
fi
# The SUPERVISOR_NIX variable must be set
[ -z "''${SUPERVISOR_NIX:-}" ] && echo "SUPERVISOR_NIX env var must be set -- aborting" && exit 1
Expand Down Expand Up @@ -226,7 +186,6 @@ let
SUPERVISORD_CONFIG = task_supervisord_conf;
SUPERVISORD_LOGLEVEL = task_supervisord_loglevel;
ONE_TRACER_PER_NODE = oneTracerPerNode;
GENESIS_HTTP_ARTIFACT_SOURCE = "http://127.0.0.1:12000";
};

# A group defines a series of tasks that should be co-located
Expand Down Expand Up @@ -599,16 +558,6 @@ let
then {
driver = "exec";

# TODO: Make it download to NOMAD_ALLOC_DIR and share it!
# https://developer.hashicorp.com/nomad/docs/job-specification/artifact#destination
# https://developer.hashicorp.com/nomad/docs/runtime/environment#task-directories
# https://github.com/hashicorp/nomad/issues/1368
artifact = {
source = "\${NOMAD_META_GENESIS_HTTP_ARTIFACT_SOURCE}/\${NOMAD_JOB_NAME}.tar.zst?archive=false";
destination = "local/run/current/genesis.tar.zst";
mode = "file";
};

config = {

command = "${containerSpecs.containerPkgs.bashInteractive.nix-store-path}/bin/bash";
Expand Down
24 changes: 17 additions & 7 deletions nix/workbench/backend/nomad.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ let
src = pkgs.fetchFromGitHub { # "github:input-output-hk/nomad/release/1.4.3"
owner = "input-output-hk";
repo = pname;
rev = "release/${version}";
# nix-prefetch-url --unpack https://github.com/input-output-hk/nomad/archive/release/1.4.3.tar.gz
sha256 = "0z4bdx0nx6460q9r032l8ghx337h3fpi6cx8wh7i3qllpyi51a2k";
rev = "2b8a93390"; # Use to be "release/${version}" but it changes.
# nix-prefetch-url --unpack https://github.com/input-output-hk/nomad/archive/2b8a93390/1.4.3.tar.gz
sha256 = "0l2sfhpg0p5mjdbipib7q63wlsrczr2fkq9xi641vhgxsjmprvwm";
};
# error: either `vendorHash` or `vendorSha256` is required
# https://discourse.nixos.org/t/buildgomodule-how-to-get-vendorsha256/9317
Expand Down Expand Up @@ -79,9 +79,13 @@ let
else [ nomad-sre ]
)
++
# Network tools to be able to use bridge networking and the HTTP server
# to upload/download the genesis tar file.
[ pkgs.cni-plugins pkgs.webfs ]
[
# Network tools to be able to use bridge networking and the HTTP server
# to upload/download the genesis tar file.
pkgs.cni-plugins pkgs.webfs
# Amazon S3 HTTP to upload the genesis.
pkgs.awscli
]
;

# Backend-specific Nix bits:
Expand Down Expand Up @@ -137,7 +141,13 @@ let
zstd = rec {
nix-store-path = pkgs.zstd;
flake-reference = "github:input-output-hk/cardano-node";
flake-output = "legacyPackages.x86_64-linux.gnutar";
flake-output = "legacyPackages.x86_64-linux.zstd";
installable = "${flake-reference}/${gitrev}#${flake-output}";
};
wget = rec {
nix-store-path = pkgs.wget;
flake-reference = "github:input-output-hk/cardano-node";
flake-output = "legacyPackages.x86_64-linux.wget";
installable = "${flake-reference}/${gitrev}#${flake-output}";
};
supervisor = rec {
Expand Down
Loading

0 comments on commit aa7f365

Please sign in to comment.