From 97bd7a00f1b20cf89439beddd5b787e3d79a1577 Mon Sep 17 00:00:00 2001 From: Pankaj Garg Date: Mon, 1 Apr 2019 22:54:41 +0000 Subject: [PATCH] Support for configuring testnet nodes across multiple cloud services --- net/common.sh | 4 +- net/gce.sh | 115 +++++++++++++++++++++++++++++++------------------- net/net.sh | 1 + 3 files changed, 76 insertions(+), 44 deletions(-) diff --git a/net/common.sh b/net/common.sh index cc0e02250..04970bb62 100644 --- a/net/common.sh +++ b/net/common.sh @@ -24,6 +24,7 @@ entrypointIp= publicNetwork= netBasename= sshPrivateKey= +externalNodeSshKey= sshOptions=() fullnodeIpList=() fullnodeIpListPrivate=() @@ -41,8 +42,9 @@ buildSshOptions() { -o "User=solana" -o "IdentityFile=$sshPrivateKey" -o "LogLevel=ERROR" - -F /dev/null ) + + [[ -z $externalNodeSshKey ]] || sshOptions+=(-o "IdentityFile=$externalNodeSshKey") } loadConfigFile() { diff --git a/net/gce.sh b/net/gce.sh index 52fb2201f..ce35fd644 100755 --- a/net/gce.sh +++ b/net/gce.sh @@ -42,6 +42,7 @@ clientNodeCount=1 blockstreamer=false fullNodeBootDiskSizeInGb=1000 clientBootDiskSizeInGb=75 +externalNodes=false publicNetwork=false enableGpu=false @@ -114,7 +115,7 @@ shift [[ $command = create || $command = config || $command = info || $command = delete ]] || usage "Invalid command: $command" -while getopts "h?p:Pn:c:z:gG:a:d:bu" opt; do +while getopts "h?p:Pn:c:z:gG:a:d:bux" opt; do case $opt in h | \?) usage @@ -157,6 +158,9 @@ while getopts "h?p:Pn:c:z:gG:a:d:bu" opt; do u) blockstreamer=true ;; + x) + externalNodes=true + ;; *) usage "unhandled option: $opt" ;; @@ -219,13 +223,18 @@ cloud_ForEachInstance() { prepareInstancesAndWriteConfigFile() { $metricsWriteDatapoint "testnet-deploy net-config-begin=1" - cat >> "$configFile" <> "$configFile" + else + cat >> "$configFile" <> "$configFile" - echo "fullnodeIpListPrivate=()" >> "$configFile" - cloud_ForEachInstance recordInstanceIp fullnodeIpList - cloud_ForEachInstance waitForStartupComplete + echo "fullnodeIpList=()" >> "$configFile" + echo "fullnodeIpListPrivate=()" >> "$configFile" + cloud_ForEachInstance recordInstanceIp fullnodeIpList + cloud_ForEachInstance waitForStartupComplete + fi echo "Looking for additional fullnode instances..." for zone in "${zones[@]}"; do @@ -314,8 +327,12 @@ EOF cloud_ForEachInstance waitForStartupComplete done - echo "clientIpList=()" >> "$configFile" - echo "clientIpListPrivate=()" >> "$configFile" + if $externalNodes; then + echo "Let's not reset the current client configuration" + else + echo "clientIpList=()" >> "$configFile" + echo "clientIpListPrivate=()" >> "$configFile" + fi echo "Looking for client bencher instances..." cloud_FindInstances "$prefix-client" [[ ${#instances[@]} -eq 0 ]] || { @@ -323,8 +340,12 @@ EOF cloud_ForEachInstance waitForStartupComplete } - echo "blockstreamerIpList=()" >> "$configFile" - echo "blockstreamerIpListPrivate=()" >> "$configFile" + if $externalNodes; then + echo "Let's not reset the current blockstream configuration" + else + echo "blockstreamerIpList=()" >> "$configFile" + echo "blockstreamerIpListPrivate=()" >> "$configFile" + fi echo "Looking for blockstreamer instances..." cloud_FindInstances "$prefix-blockstreamer" [[ ${#instances[@]} -eq 0 ]] || { @@ -360,7 +381,11 @@ delete() { cloud_DeleteInstances true fi done - rm -f "$configFile" + if $externalNodes; then + echo "Let's not delete the current configuration file" + else + rm -f "$configFile" + fi $metricsWriteDatapoint "testnet-deploy net-delete-complete=1" @@ -474,9 +499,13 @@ EOF cloud_Initialize "$prefix" "$zone" done - cloud_CreateInstances "$prefix" "$prefix-bootstrap-leader" 1 \ - "$enableGpu" "$bootstrapLeaderMachineType" "${zones[0]}" "$fullNodeBootDiskSizeInGb" \ - "$startupScript" "$bootstrapLeaderAddress" "$bootDiskType" + if $externalNodes; then + echo "Bootstrap leader is already configured" + else + cloud_CreateInstances "$prefix" "$prefix-bootstrap-leader" 1 \ + "$enableGpu" "$bootstrapLeaderMachineType" "${zones[0]}" "$fullNodeBootDiskSizeInGb" \ + "$startupScript" "$bootstrapLeaderAddress" "$bootDiskType" + fi num_zones=${#zones[@]} numNodesPerZone=$((additionalFullNodeCount / num_zones)) diff --git a/net/net.sh b/net/net.sh index fd0a26465..d5fff2d55 100755 --- a/net/net.sh +++ b/net/net.sh @@ -163,6 +163,7 @@ startCommon() { mkdir -p ~/.cargo/bin " fi + ssh-copy-id -f -i "$externalNodeSshKey" "${sshOptions[@]}" "solana@$ipAddress" rsync -vPrc -e "ssh ${sshOptions[*]}" \ "$SOLANA_ROOT"/{fetch-perf-libs.sh,scripts,net,multinode-demo} \ "$ipAddress":~/solana/