Skip to content

Commit

Permalink
workbench: Distribute genesis using an intermediate storage service
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaste committed Mar 17, 2023
1 parent c265817 commit fdee05b
Show file tree
Hide file tree
Showing 6 changed files with 298 additions and 169 deletions.
1 change: 1 addition & 0 deletions nix/workbench/backend/backend.sh
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
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
26 changes: 20 additions & 6 deletions nix/workbench/backend/nomad.nix
Expand Up @@ -46,13 +46,17 @@ let
src = pkgs.fetchFromGitHub { # "github:input-output-hk/nomad/release/1.4.3"
owner = "input-output-hk";
repo = pname;
rev = "release/${version}";
rev = "2b8a93390";
# rev = "release/${version}";
# nix-prefetch-url --unpack https://github.com/input-output-hk/nomad/archive/2b8a93390/1.4.3.tar.gz
# nix-prefetch-url --unpack https://github.com/input-output-hk/nomad/archive/release/1.4.3.tar.gz
sha256 = "0z4bdx0nx6460q9r032l8ghx337h3fpi6cx8wh7i3qllpyi51a2k";
sha256 = "0l2sfhpg0p5mjdbipib7q63wlsrczr2fkq9xi641vhgxsjmprvwm";
#sha256 = "0z4bdx0nx6460q9r032l8ghx337h3fpi6cx8wh7i3qllpyi51a2k";
};
# error: either `vendorHash` or `vendorSha256` is required
# https://discourse.nixos.org/t/buildgomodule-how-to-get-vendorsha256/9317
vendorSha256 = "sha256-JQRpsQhq5r/QcgFwtnptmvnjBEhdCFrXFrTKkJioL3A=";
# vendorSha256 = "sha256-JQRpsQhq5r/QcgFwtnptmvnjBEhdCFrXFrTKkJioL3A=";
});
# This plugin is defined but only used if `execTaskDriver` is false.
nomad-driver-podman = (pkgs.buildGo119Module rec {
Expand All @@ -79,9 +83,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
# OpenSSL to sign Amazon S3 HTTP requests when uploading the genesis.
pkgs.openssl
]
;

# Backend-specific Nix bits:
Expand Down Expand Up @@ -137,7 +145,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

0 comments on commit fdee05b

Please sign in to comment.