Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: prime-node / vector-node / readiness probe #54

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions bootstrap/configs/prime-testnet/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"ByronGenesisFile": "/genesis/byron/genesis.json",
"ShelleyGenesisFile": "/genesis/shelley/genesis.json",
"AlonzoGenesisFile": "/genesis/shelley/genesis.alonzo.json",
"ConwayGenesisFile": "/genesis/shelley/genesis.conway.json",
"ByronGenesisHash": "acd3e7c4cc071ae176fa253e654f0dd4e759892b16e958d8bd3c393f5c6c66d2",
"ShelleyGenesisHash": "0b67b0cb16e973478888efb1c7f69fca8e80489369afed94624a588e94a94f2b",
"AlonzoGenesisHash": "0f715ff78fcab739c6cb2cc1073eb87d0ffe3514218bfa0337d416f6fbaf7886",
"ConwayGenesisHash": "d43d3f38e01848bddf67e66fe29fbd236aca252de58c7f2c1904c67107c17842",
"SocketPath": "db/node.socket",
"PBftSignatureThreshold": 0.6,
"MaxConcurrencyBulkSync": 1,
"MaxConcurrencyDeadline": 2,
"Protocol": "Cardano",
"RequiresNetworkMagic": "RequiresMagic",
"LastKnownBlockVersion-Major": 6,
"LastKnownBlockVersion-Minor": 0,
"LastKnownBlockVersion-Alt": 0,
"TurnOnLogging": true,
"TurnOnLogMetrics": true,
"minSeverity": "Debug",
"TracingVerbosity": "NormalVerbosity",
"setupBackends": ["KatipBK"],
"defaultBackends": ["KatipBK"],
"hasEKG": 12788,
"hasPrometheus": [
"0.0.0.0",
12798
],
"setupScribes": [
{
"scKind": "StdoutSK",
"scName": "stdout",
"scFormat": "ScText"
}
],
"defaultScribes": [
["StdoutSK", "stdout"]
],
"rotation": {
"rpLogLimitBytes": 5000000,
"rpKeepFilesNum": 3,
"rpMaxAgeHours": 24
},
"TraceBlockFetchClient": false,
"TraceBlockFetchDecisions": false,
"TraceBlockFetchProtocol": false,
"TraceBlockFetchProtocolSerialised": false,
"TraceBlockFetchServer": false,
"TraceBlockchainTime": false,
"TraceChainDb": true,
"TraceChainSyncClient": false,
"TraceChainSyncBlockServer": false,
"TraceChainSyncHeaderServer": false,
"TraceChainSyncProtocol": false,
"TraceDNSResolver": true,
"TraceDNSSubscription": true,
"TraceErrorPolicy": true,
"TraceLocalErrorPolicy": true,
"TraceForge": true,
"TraceHandshake": false,
"TraceIpSubscription": true,
"TraceLocalRootPeers": true,
"TracePublicRootPeers": true,
"TracePeerSelection": true,
"TraceDebugPeerSelection": false,
"TracePeerSelectionActions": true,
"TraceConnectionManager": true,
"TraceServer": true,
"TraceLocalConnectionManager": false,
"TraceLocalServer": false,
"TraceLocalChainSyncProtocol": false,
"TraceLocalHandshake": false,
"TraceLocalTxSubmissionProtocol": false,
"TraceLocalTxSubmissionServer": false,
"TraceMempool": true,
"TraceMux": false,
"TraceTxInbound": false,
"TraceTxOutbound": false,
"TraceTxSubmissionProtocol": false,
"options": {
"mapBackends": {
"cardano.node.metrics": ["EKGViewBK"]
},
"mapScribes": {
"cardano.node.metrics": ["FileSK::logs/mainnet.log"]
},
"mapSeverity": {
"cardano.node.ChainDB": "Notice",
"cardano.node.DnsSubscription": "Debug"
}
},
"TestShelleyHardForkAtEpoch": 0,
"TestAllegraHardForkAtEpoch": 0,
"TestMaryHardForkAtEpoch": 0,
"TestAlonzoHardForkAtEpoch": 0,
"TestBabbageHardForkAtEpoch": 0,
"ExperimentalProtocolsEnabled": true,
"EnableP2P": true,
"TargetNumberOfRootPeers": 20,
"TargetNumberOfKnownPeers": 20,
"TargetNumberOfEstablishedPeers": 10,
"TargetNumberOfActivePeers": 10,
"TraceInboundGovernorCounters": true,
"TraceConnectionManagerTransitions": true,
"TraceLedgerPeers": true,
"TracePeerSelectionCounters": true,
"TracePeerStateActions": true
}
14 changes: 14 additions & 0 deletions bootstrap/configs/prime-testnet/topology.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"localRoots": [
],
"publicRoots" : [
{ "accessPoints": [
{ "address": "relay-0.prime.testnet.apexfusion.org", "port": 5521 },
{ "address": "relay-1.prime.testnet.apexfusion.org", "port": 5521 }
],
"advertise": true,
"valency": 1
}
],
"useLedgerAfterSlot": 0
}
10 changes: 10 additions & 0 deletions bootstrap/feature/config.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "kubernetes_config_map" "node-readiness" {
metadata {
namespace = var.namespace
name = "node-readiness"
}

data = {
"readiness.sh" = "${file("${path.module}/readiness.sh")}"
}
}
33 changes: 33 additions & 0 deletions bootstrap/feature/readiness.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

if ! command -v jq &> /dev/null; then
echo "Error: jq is not installed. Please install jq to use this script."
exit 1
fi

if ! command -v cardano-cli &> /dev/null; then
echo "Error: cardano-cli is not installed. Please install cardano-cli to use this script."
exit 1
fi

if ! command -v bc &> /dev/null; then
echo "Error: bc is not installed. Please install bc to use this script."
exit 1
fi

if [ "$CARDANO_NODE_NETWORK_ID" == "764824073" ]; then
JSON_DATA=$(cardano-cli query tip --mainnet)
else
JSON_DATA=$(cardano-cli query tip --testnet-magic "$CARDANO_NODE_NETWORK_ID")
fi

SYNC_PROGRESS=$(echo "$JSON_DATA" | jq -r '.syncProgress')
MIN_EXPECTED_SYNC_PROGRESS="99.00"
MAX_EXPECTED_SYNC_PROGRESS="100.00"

if (( $(echo "$SYNC_PROGRESS >= $MIN_EXPECTED_SYNC_PROGRESS" | bc -l) )) && (( $(echo "$SYNC_PROGRESS <= $MAX_EXPECTED_SYNC_PROGRESS" | bc -l) )); then
echo "syncProgress is within the acceptable range of 99 to 100"
else
echo "Error: syncProgress is not within the acceptable range of 99 to 100"
exit 1
fi
54 changes: 49 additions & 5 deletions bootstrap/instance/node.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ locals {
"--port",
"3000"
]
arguments = var.is_custom == true ? local.custom_arguments : local.default_arguments
arguments = var.network == "vector-testnet" ? [] : var.is_custom == true ? local.custom_arguments : local.default_arguments

n2n_port_name = contains(["mainnet", "preview", "preprod"], var.network) && var.release == "stable" ? "n2n-${var.network}" : "n2n"
}
Expand Down Expand Up @@ -157,6 +157,14 @@ resource "kubernetes_stateful_set_v1" "node" {
}
}

volume {
name = "node-readiness"
config_map {
name = "node-readiness"
default_mode = "0500"
}
}

container {
image = "${var.node_image}:${var.node_image_tag}"
name = "main"
Expand All @@ -173,6 +181,33 @@ resource "kubernetes_stateful_set_v1" "node" {
value = var.restore
}

env {
name = "CARDANO_NODE_SOCKET_PATH"
value = "/ipc/node.socket"
}

env {
name = "CARDANO_NODE_NETWORK_ID"
value = var.magic
}

dynamic "env" {
for_each = var.network == "vector-testnet" ? toset([1]) : toset([])

content {
name = "PORT"
value = "3000"
}
}

dynamic "env" {
for_each = var.network == "vector-testnet" ? toset([1]) : toset([])
content {
name = "NETWORK"
value = "testnet"
}
}

resources {
limits = var.node_resources.limits
requests = var.node_resources.requests
Expand All @@ -198,6 +233,11 @@ resource "kubernetes_stateful_set_v1" "node" {
name = "ipc"
}

volume_mount {
mount_path = "/probes"
name = "node-readiness"
}

dynamic "volume_mount" {
for_each = var.is_custom == true ? toset([1]) : toset([])

Expand All @@ -207,10 +247,14 @@ resource "kubernetes_stateful_set_v1" "node" {
}
}

readiness_probe {
initial_delay_seconds = 20
exec {
command = ["test", "-S", "/ipc/node.socket"]
dynamic "readiness_probe" {
for_each = var.network != "vector-testnet" ? toset([1]) : toset([])

content {
initial_delay_seconds = 20
exec {
command = ["/probes/readiness.sh"]
}
}
}
}
Expand Down
Loading