Skip to content

Commit

Permalink
CAD-2548 supervisord: describe the profile being used
Browse files Browse the repository at this point in the history
  • Loading branch information
deepfire authored and jutaro committed May 13, 2021
1 parent 9931366 commit bd116c4
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 21 deletions.
24 changes: 15 additions & 9 deletions nix/supervisord-cluster/default.nix
Expand Up @@ -89,16 +89,24 @@ let
if [ -f ${stateDir}/supervisord.pid ]
then echo "Cluster already running. Please run 'stop-cluster' first!"
exit 1
else cat <<EOF
exit 1; fi
cat <<EOF
Starting cluster:
- profile: ${profile.name}
- profile JSON: ${profileJSONFile}
- state dir: ${stateDir}
- topology: ${topologyNixopsFile}
- state dir: ${stateDir}
- topology: ${topologyNixopsFile}, ${topology.topologyPdf}
- node port base: ${toString basePort}
- EKG URLs: http://localhost:${toString (node-setups.nodeIndexToEkgPort 0)}/
- Prometheus URLs: http://localhost:${toString (node-setups.nodeIndexToPrometheusPort 0)}/metrics
- profile JSON: ${profileJSONFile}
EOF
fi
${pkgs.jq}/bin/jq '
include "profiles/derived" { search: "${./.}" };
profile_pretty_describe(.)
' ${profileJSONFile} --raw-output
rm -rf ${stateDir}
Expand All @@ -109,8 +117,6 @@ EOF
${mkGenesisBash}
echo "Profile '${profile.name}' dump in: ${profileJSONFile}"
${__concatStringsSep "\n"
(flip mapAttrsToList node-setups.nodeSetups
(name: nodeSetup:
Expand Down
13 changes: 3 additions & 10 deletions nix/supervisord-cluster/genesis.nix
Expand Up @@ -227,7 +227,7 @@ let
if test -f "$genesis_cache_path"/cache.params.id
then genesis_cache_hit=t; genesis_cache_hit_desc='hit'
else genesis_cache_hit=; genesis_cache_hit_desc='miss'; fi
echo "genesis cache $genesis_cache_hit_desc: $genesis_cache_id"
echo "Genesis cache $genesis_cache_hit_desc: $genesis_cache_id"
regenesis_causes=()
if test -z "$genesis_cache_hit"
Expand All @@ -237,7 +237,7 @@ let
fi
if test -n "''${regenesis_causes[*]}"
then echo "generating genesis due to ''${regenesis_causes[*]}: $genesis_cache_id @$genesis_cache_path"
then echo "..generating genesis due to ''${regenesis_causes[*]}: $genesis_cache_id @$genesis_cache_path"
rm -rf "$genesis_cache_path"/{*-keys,pools,nodes,*.json,*.params}
mkdir -p "$genesis_cache_path"
Expand Down Expand Up @@ -321,12 +321,5 @@ in
${shelleyGenesis}
cat <<EOF
Generated genesis for ${name} (cache id $genesis_cache_id):
- BFT hosts: ${toString composition.n_bft_hosts}
- pool hosts: ${toString (composition.n_hosts - composition.n_bft_hosts)}
- pools: ${toString composition.n_pools}, of them:
- regular: ${toString composition.n_singular_pools}
- dense: ${toString composition.n_dense_pools}, at ${toString composition.dense_pool_density} density in ${toString composition.n_dense_hosts} hosts
EOF
echo "Generated genesis for ${name} (cache id $genesis_cache_id)"
''
8 changes: 6 additions & 2 deletions nix/supervisord-cluster/node-setups.nix
Expand Up @@ -45,6 +45,9 @@ let
};
in f envConfig eval.config.services.cardano-node;

nodeIndexToEkgPort = i: basePort + 100 + i;
nodeIndexToPrometheusPort = i: basePort + 200 + i;

##
## nodeSpecEnvConfig :: NodeSpec -> EnvConfig
##
Expand All @@ -54,8 +57,8 @@ let
baseEnvConfig
({ nodeConfig =
{
hasEKG = 30100 + i;
hasPrometheus = [ "127.0.0.1" (30200 + i) ];
hasEKG = nodeIndexToEkgPort i;
hasPrometheus = [ "127.0.0.1" (nodeIndexToPrometheusPort i) ];

TracingVerbosity = "NormalVerbosity";
minSeverity = "Debug";
Expand Down Expand Up @@ -115,4 +118,5 @@ let
in
{
inherit nodeSetups;
inherit nodeIndexToEkgPort nodeIndexToPrometheusPort;
}
17 changes: 17 additions & 0 deletions nix/supervisord-cluster/profiles/derived.jq
Expand Up @@ -123,3 +123,20 @@ def add_derived_params:
, cli_args: profile_cli_args(.)
}
;

def profile_pretty_describe($p):
[ "Profile: \($p.name)"
, " - era: \($p.era)"
, " - epoch slots: \($p.genesis.epoch_length)"
, " - slot duration: \($p.genesis.slot_duration)"
, " - k: \($p.genesis.parameter_k)"
, " - active slots coeff: \($p.genesis.active_slots_coeff)"
, " - hosts: \($p.composition.n_hosts)"
, " - pools: \($p.composition.n_pools)"
, " - normal: \($p.composition.n_singular_pools)"
, " - dense: \($p.composition.n_dense_pools)"
, " - UTxO: \($p.genesis.utxo)"
, " - delegators: \($p.genesis.delegators)"
, ""
]
| join("\n");
2 changes: 2 additions & 0 deletions nix/supervisord-cluster/topology.nix
Expand Up @@ -55,6 +55,8 @@ in
inherit i;
}));

topologyPdf = "${stateDir}/topology.pdf";

mkTopologyBash =
''
mkdir -p "${stateDir}/topologies"
Expand Down

0 comments on commit bd116c4

Please sign in to comment.