diff --git a/templates/terraform/hetzner/bootstrap_node_evm_provisioner.tf b/templates/terraform/hetzner/bootstrap_node_evm_provisioner.tf index 2fb5ed1e..606e927e 100644 --- a/templates/terraform/hetzner/bootstrap_node_evm_provisioner.tf +++ b/templates/terraform/hetzner/bootstrap_node_evm_provisioner.tf @@ -45,6 +45,19 @@ resource "null_resource" "setup-bootstrap-nodes-evm" { } +resource "null_resource" "clone_branch" { + count = var.branch != "main" ? 1 : 0 + + provisioner "remote-exec" { + inline = [ + "cd /root/subspace/", + "git clone https://github.com/subspace/subspace.git", + "cd subspace", + "git checkout ${var.branch_name}" + ] + } +} + resource "null_resource" "prune-bootstrap-nodes-evm" { count = var.bootstrap-node-evm-config.prune ? length(local.bootstrap_nodes_evm_ip_v4) : 0 depends_on = [null_resource.setup-bootstrap-nodes-evm] @@ -135,8 +148,8 @@ resource "null_resource" "start-bootstrap-nodes-evm" { "sudo hostnamectl set-hostname ${var.network_name}-bootstrap-node-evm-${count.index}", # create .env file - "echo NODE_ORG=${var.bootstrap-node-evm-config.docker-org} > /root/subspace/.env", - "echo NODE_TAG=${var.bootstrap-node-evm-config.docker-tag} >> /root/subspace/.env", + "echo NODE_ORG=${var.bootstrap-node-evm-config.repo-org} > /root/subspace/.env", + "echo NODE_TAG=${var.bootstrap-node-evm-config.node-tag} >> /root/subspace/.env", "echo NETWORK_NAME=${var.network_name} >> /root/subspace/.env", "echo NODE_ID=${count.index} >> /root/subspace/.env", "echo NODE_KEY=$(sed -nr 's/NODE_${count.index}_KEY=//p' /root/subspace/node_keys.txt) >> /root/subspace/.env", @@ -151,12 +164,16 @@ resource "null_resource" "start-bootstrap-nodes-evm" { "echo NODE_DSN_PORT=${var.bootstrap-node-evm-config.node-dsn-port} >> /root/subspace/.env", "echo OPERATOR_PORT=${var.bootstrap-node-evm-config.operator-port} >> /root/subspace/.env", "echo GENESIS_HASH=${var.bootstrap-node-evm-config.genesis-hash} >> /root/subspace/.env", + "echo BRANCH_NAME=${var.branch_name} >> /root/subspace/.env", # create docker compose file - "bash /root/subspace/create_compose_file.sh ${var.bootstrap-node-evm-config.reserved-only} ${length(local.bootstrap_nodes_evm_ip_v4)} ${count.index} ${length(local.bootstrap_nodes_ip_v4)} ${var.domain-node-config.enable-domains} ", + "bash /root/subspace/create_compose_file.sh ${var.bootstrap-node-evm-config.reserved-only} ${length(local.bootstrap_nodes_evm_ip_v4)} ${count.index} ${length(local.bootstrap_nodes_ip_v4)} ${var.domain-node-config.enable-domains}", # start subspace node - "sudo docker compose -f /root/subspace/subspace/docker-compose.yml up -d", + var.branch != "main" ? join(" && ", [ + "cp -f /root/subspace/.env /root/subspace/subspace/.env", + "sudo docker compose -f /root/subspace/subspace/docker-compose.yml up -d" + ]) : "sudo docker compose -f /root/subspace/docker-compose.yml up -d" ] } } diff --git a/templates/terraform/hetzner/bootstrap_node_provisioner.tf b/templates/terraform/hetzner/bootstrap_node_provisioner.tf index 47563744..12955f33 100644 --- a/templates/terraform/hetzner/bootstrap_node_provisioner.tf +++ b/templates/terraform/hetzner/bootstrap_node_provisioner.tf @@ -43,8 +43,11 @@ resource "null_resource" "setup-bootstrap-nodes" { "sudo bash /root/subspace/installer.sh", ] } +} + +resource "null_resource" "clone_branch" { + count = var.branch != "main" ? 1 : 0 - # clone testing branch provisioner "remote-exec" { inline = [ "cd /root/subspace/", @@ -53,7 +56,6 @@ resource "null_resource" "setup-bootstrap-nodes" { "git checkout ${var.branch_name}" ] } - } resource "null_resource" "prune-bootstrap-nodes" { @@ -146,14 +148,16 @@ resource "null_resource" "start-boostrap-nodes" { "echo DSN_LISTEN_PORT=${var.bootstrap-node-config.dsn-listen-port} >> /root/subspace/.env", "echo NODE_DSN_PORT=${var.bootstrap-node-config.node-dsn-port} >> /root/subspace/.env", "echo GENESIS_HASH=${var.bootstrap-node-config.genesis-hash} >> /root/subspace/.env", + "echo BRANCH_NAME=${var.branch_name} >> /root/subspace/.env", # create docker compose file - "chmod +x /root/subspace/create_compose_file.sh", "bash /root/subspace/create_compose_file.sh ${var.bootstrap-node-config.reserved-only} ${length(local.bootstrap_nodes_ip_v4)} ${count.index}", # start subspace node - "cp -f /root/subspace/.env /root/subspace/subspace/.env", - "sudo docker compose -f /root/subspace/subspace/docker-compose.yml up -d", + var.branch != "main" ? join(" && ", [ + "cp -f /root/subspace/.env /root/subspace/subspace/.env", + "sudo docker compose -f /root/subspace/subspace/docker-compose.yml up -d" + ]) : "sudo docker compose -f /root/subspace/docker-compose.yml up -d" ] } } diff --git a/templates/terraform/hetzner/domain_node_provisioner.tf b/templates/terraform/hetzner/domain_node_provisioner.tf index 76e16d7a..2c34ba77 100644 --- a/templates/terraform/hetzner/domain_node_provisioner.tf +++ b/templates/terraform/hetzner/domain_node_provisioner.tf @@ -42,7 +42,11 @@ resource "null_resource" "setup-domain-nodes" { "sudo bash /root/subspace/installer.sh", ] } - # clone testing branch +} + +resource "null_resource" "clone_branch" { + count = var.branch != "main" ? 1 : 0 + provisioner "remote-exec" { inline = [ "cd /root/subspace/", @@ -51,7 +55,6 @@ resource "null_resource" "setup-domain-nodes" { "git checkout ${var.branch_name}" ] } - } resource "null_resource" "prune-domain-nodes" { @@ -163,38 +166,16 @@ resource "null_resource" "start-domain-nodes" { "echo RELAYER_DOMAIN_ID=$(sed -nr 's/NODE_${count.index}_RELAYER_DOMAIN_ID=//p' /root/subspace/relayer_ids.txt) >> /root/subspace/.env", "echo PIECE_CACHE_SIZE=${var.piece_cache_size} >> /root/subspace/.env", "echo NODE_DSN_PORT=${var.domain-node-config.node-dsn-port} >> /root/subspace/.env", + "echo BRANCH_NAME=${var.branch_name} >> /root/subspace/.env", # create docker compose file "bash /root/subspace/create_compose_file.sh ${var.bootstrap-node-config.reserved-only} ${length(local.domain_node_ip_v4)} ${count.index} ${length(local.bootstrap_nodes_ip_v4)} ${var.domain-node-config.enable-domains} ${var.domain-node-config.domain-id[0]}", # start subspace node - "cp -f /root/subspace/.env /root/subspace/subspace/.env", - "sudo docker compose -f /root/subspace/subspace/docker-compose.yml up -d", - ] - } -} - -resource "null_resource" "inject-domain-keystore" { - # for now we have one executor running. Should change here when multiple executors are expected. - count = length(local.domain_node_ip_v4) > 0 ? 1 : 0 - depends_on = [null_resource.start-domain-nodes] - # trigger on node deployment version change - triggers = { - deployment_version = var.domain-node-config.deployment-version - } - - connection { - host = local.domain_node_ip_v4[0] - user = var.ssh_user - type = "ssh" - agent = true - private_key = file("${var.private_key_path}") - timeout = "300s" - } - - provisioner "remote-exec" { - inline = [ - "sudo docker cp /root/subspace/keystore/. subspace-archival-node-1:/var/subspace/keystore/" + var.branch != "main" ? join(" && ", [ + "cp -f /root/subspace/.env /root/subspace/subspace/.env", + "sudo docker compose -f /root/subspace/subspace/docker-compose.yml up -d" + ]) : "sudo docker compose -f /root/subspace/docker-compose.yml up -d" ] } } diff --git a/templates/terraform/hetzner/farmer_node_provisioner.tf b/templates/terraform/hetzner/farmer_node_provisioner.tf index 46377c1a..3667cd3d 100644 --- a/templates/terraform/hetzner/farmer_node_provisioner.tf +++ b/templates/terraform/hetzner/farmer_node_provisioner.tf @@ -45,8 +45,11 @@ resource "null_resource" "setup-farmer-nodes" { "sudo /root/subspace/installer.sh", ] } +} + +resource "null_resource" "clone_branch" { + count = var.branch != "main" ? 1 : 0 - # clone testing branch provisioner "remote-exec" { inline = [ "cd /root/subspace/", @@ -55,7 +58,6 @@ resource "null_resource" "setup-farmer-nodes" { "git checkout ${var.branch_name}" ] } - } resource "null_resource" "prune-farmer-nodes" { @@ -152,14 +154,16 @@ resource "null_resource" "start-farmer-nodes" { "echo PLOT_SIZE=${var.farmer-node-config.plot-size} >> /root/subspace/.env", "echo PIECE_CACHE_SIZE=${var.piece_cache_size} >> /root/subspace/.env", "echo NODE_DSN_PORT=${var.farmer-node-config.node-dsn-port} >> /root/subspace/.env", + "echo BRANCH_NAME=${var.branch_name} >> /root/subspace/.env", # create docker compose file - "chmod +x /root/subspace/create_compose_file.sh", "bash /root/subspace/create_compose_file.sh ${var.bootstrap-node-config.reserved-only} ${length(local.farmer_node_ipv4)} ${count.index} ${length(local.bootstrap_nodes_ip_v4)} ${var.farmer-node-config.force-block-production}", - # start subspace - "cp -f /root/subspace/.env /root/subspace/subspace/.env", - "sudo docker compose -f /root/subspace/subspace/docker-compose.yml up -d", + # start subspace node + var.branch != "main" ? join(" && ", [ + "cp -f /root/subspace/.env /root/subspace/subspace/.env", + "sudo docker compose -f /root/subspace/subspace/docker-compose.yml up -d" + ]) : "sudo docker compose -f /root/subspace/docker-compose.yml up -d" ] } } diff --git a/templates/terraform/hetzner/node_provisioner.tf b/templates/terraform/hetzner/node_provisioner.tf index 66dc31b5..0d98e448 100644 --- a/templates/terraform/hetzner/node_provisioner.tf +++ b/templates/terraform/hetzner/node_provisioner.tf @@ -43,8 +43,11 @@ resource "null_resource" "setup-nodes" { "sudo bash /root/subspace/installer.sh", ] } +} + +resource "null_resource" "clone_branch" { + count = var.branch != "main" ? 1 : 0 - # clone testing branch provisioner "remote-exec" { inline = [ "cd /root/subspace/", @@ -53,7 +56,6 @@ resource "null_resource" "setup-nodes" { "git checkout ${var.branch_name}" ] } - } resource "null_resource" "prune-nodes" { @@ -148,14 +150,16 @@ resource "null_resource" "start-nodes" { "echo NODE_KEY=$(sed -nr 's/NODE_${count.index}_KEY=//p' /root/subspace/node_keys.txt) >> /root/subspace/.env", "echo PIECE_CACHE_SIZE=${var.piece_cache_size} >> /root/subspace/.env", "echo NODE_DSN_PORT=${var.node-config.node-dsn-port} >> /root/subspace/.env", + "echo BRANCH_NAME=${var.branch_name} >> /root/subspace/.env", # create docker compose file - "chmod +x /root/subspace/create_compose_file.sh", "bash /root/subspace/create_compose_file.sh ${var.bootstrap-node-config.reserved-only} ${length(local.node_ip_v4)} ${count.index} ${length(local.bootstrap_nodes_ip_v4)}", # start subspace node - "cp -f /root/subspace/.env /root/subspace/subspace/.env", - "sudo docker compose -f /root/subspace/subspace/docker-compose.yml up -d", + var.branch != "main" ? join(" && ", [ + "cp -f /root/subspace/.env /root/subspace/subspace/.env", + "sudo docker compose -f /root/subspace/subspace/docker-compose.yml up -d" + ]) : "sudo docker compose -f /root/subspace/docker-compose.yml up -d" ] } }