diff --git a/changelog.d/5-bug-fixes/fix-unavailable-server-types b/changelog.d/5-bug-fixes/fix-unavailable-server-types index 028cea26c..a03d5aaa4 100644 --- a/changelog.d/5-bug-fixes/fix-unavailable-server-types +++ b/changelog.d/5-bug-fixes/fix-unavailable-server-types @@ -1 +1 @@ -Fixed: subsequent provisioning retries to change server_type will not automatically tear down already deployed machines +Fixed: subsequent provisioning retries with changed server_type will not automatically tear down already deployed machines \ No newline at end of file diff --git a/changelog.d/5-bug-fixes/hetzner-retry-matrix b/changelog.d/5-bug-fixes/hetzner-retry-matrix new file mode 100644 index 000000000..47942afc7 --- /dev/null +++ b/changelog.d/5-bug-fixes/hetzner-retry-matrix @@ -0,0 +1 @@ +Fixed: Hetzner CD retry matrix only uses server types offered in EU locations (ccx as fallback) and only tears down provisioned machines when moving on to the next location diff --git a/offline/cd.sh b/offline/cd.sh index a67e9f211..0d5822f30 100755 --- a/offline/cd.sh +++ b/offline/cd.sh @@ -11,11 +11,15 @@ COMMIT_HASH="${GITHUB_SHA}" ARTIFACT="wire-server-deploy-static-${COMMIT_HASH}" # Retry matrix -# Locations are tried in order and exhaust all server types before moving on. +# Locations are tried in order and exhaust all server type pairs before moving on. # Prefer hel1: German locations rarely have capacity. -LOCATIONS=("hel1" "fsn1" "nbg1") -SMALL_SERVER_TYPES=("cx23" "cx33" "cpx22") -MEDIUM_SERVER_TYPES=("cx33" "cx43" "cpx32") +# Pairs (small/medium) are matched by index. cx* types are currently not offered +# in any EU location, so dedicated ccx types serve as fallback. +# Servers use lifecycle.ignore_changes = [server_type], so on retry only servers +# that failed to be created pick up the next pair; existing ones are kept. +LOCATIONS=("hel1" "nbg1" "fsn1") +SMALL_SERVER_TYPES=("cpx22" "cpx32" "ccx13" "ccx23") +MEDIUM_SERVER_TYPES=("cpx42" "cpx42" "ccx23" "ccx33") # Retry configuration RETRY_DELAY=30 @@ -100,8 +104,12 @@ for location_index in $(seq 0 $((location_count - 1))); do if [[ $attempt -lt $MAX_RETRIES ]]; then echo "Will retry with the next location and server type combination..." - echo "Cleaning up partial deployment..." - terraform destroy -auto-approve || true + # Keep already provisioned servers while retrying within a location; + # only tear down when moving on to the next location. + if [[ $server_type_index -eq $((server_type_count - 1)) ]]; then + echo "Location ${attempt_location} exhausted, cleaning up partial deployment..." + terraform destroy -auto-approve || true + fi echo "Waiting ${RETRY_DELAY}s for resources to become available..." sleep $RETRY_DELAY @@ -143,7 +151,7 @@ rm -f ssh_private_key || true echo "$ssh_private_key" > ssh_private_key chmod 400 ssh_private_key -# TO-DO: make changes to test the deployment with demo user in +# TO-DO: make changes to test the deployment with demo user in terraform output -json static-inventory > inventory.json yq eval -o=yaml '.' inventory.json > inventory.yml diff --git a/offline/cd_demo.sh b/offline/cd_demo.sh index 2ce41674a..297299316 100755 --- a/offline/cd_demo.sh +++ b/offline/cd_demo.sh @@ -18,8 +18,10 @@ COMMIT_HASH="${GITHUB_SHA}" # Retry matrix # Locations are tried in order and exhaust all server types before moving on. # Prefer hel1: German locations rarely have capacity. -LOCATIONS=("hel1" "fsn1" "nbg1") -SERVER_TYPES=("cx53" "cpx62") +# cx* types are currently not offered in any EU location and hel1 lacks cpx62, +# so the dedicated ccx43 (16 vCPU) serves as fallback. +LOCATIONS=("hel1" "nbg1" "fsn1") +SERVER_TYPES=("cpx62" "ccx43") # Retry configuration RETRY_DELAY=30 @@ -89,8 +91,12 @@ for location_index in $(seq 0 $((location_count - 1))); do fi if [[ $attempt -lt $MAX_RETRIES ]]; then - echo "Cleaning up partial deployment..." - terraform destroy -auto-approve || true + # Keep already provisioned resources while retrying within a location; + # only tear down when moving on to the next location. + if [[ $server_type_index -eq $((server_type_count - 1)) ]]; then + echo "Location ${attempt_location} exhausted, cleaning up partial deployment..." + terraform destroy -auto-approve || true + fi echo "Waiting ${RETRY_DELAY}s for resources to become available..." sleep $RETRY_DELAY diff --git a/offline/cd_staging.sh b/offline/cd_staging.sh index dc344a4db..d8ddb77a8 100755 --- a/offline/cd_staging.sh +++ b/offline/cd_staging.sh @@ -10,11 +10,15 @@ COMMIT_HASH="${GITHUB_SHA}" ARTIFACT="wire-server-deploy-static-${COMMIT_HASH}" # Retry matrix -# Locations are tried in order and exhaust all server types before moving on. +# Locations are tried in order and exhaust all server type pairs before moving on. # Prefer hel1: German locations rarely have capacity. +# Pairs (small/medium) are matched by index. cx* types are currently not offered +# in any EU location, so dedicated ccx types serve as fallback. +# Servers use lifecycle.ignore_changes = [server_type], so on retry only servers +# that failed to be created pick up the next pair; existing ones are kept. LOCATIONS=("hel1" "nbg1" "fsn1") -SMALL_SERVER_TYPES=("cpx22" "cpx32" "cpx42") -MEDIUM_SERVER_TYPES=("cpx42" "cpx52" "cpx62") +SMALL_SERVER_TYPES=("cpx22" "cpx32" "ccx13" "ccx23") +MEDIUM_SERVER_TYPES=("cpx42" "cpx42" "ccx23" "ccx33") # Retry configuration RETRY_DELAY=30 @@ -100,8 +104,12 @@ for location_index in $(seq 0 $((location_count - 1))); do if [[ $attempt -lt $MAX_RETRIES ]]; then echo "Will retry with the next location and server type combination..." - echo "Cleaning up partial deployment..." - terraform destroy -auto-approve || true + # Keep already provisioned servers while retrying within a location; + # only tear down when moving on to the next location. + if [[ $server_type_index -eq $((server_type_count - 1)) ]]; then + echo "Location ${attempt_location} exhausted, cleaning up partial deployment..." + terraform destroy -auto-approve || true + fi echo "Waiting ${RETRY_DELAY}s for resources to become available..." sleep $RETRY_DELAY diff --git a/terraform/examples/wiab-staging-hetzner/main.tf b/terraform/examples/wiab-staging-hetzner/main.tf index 5b4f1688a..01094e2eb 100644 --- a/terraform/examples/wiab-staging-hetzner/main.tf +++ b/terraform/examples/wiab-staging-hetzner/main.tf @@ -221,4 +221,7 @@ resource "hcloud_server" "datanode" { network_id = hcloud_network.main.id ip = "" } + lifecycle { + ignore_changes = [server_type] + } }