openvidu-deployment: shorten comments in GCP/Azure HA templates

master
Piwccle 2026-07-24 17:11:58 +02:00
parent 196b3f767f
commit b8fdde9751
3 changed files with 16 additions and 34 deletions

View File

@ -397,7 +397,6 @@ if [[ $MASTER_NODE_NUM -eq 1 ]] && [[ "$ALL_SECRETS_GENERATED" == "" || "$ALL_SE
ALL_SECRETS_GENERATED="$(/usr/local/bin/store_secret.sh save ALL-SECRETS-GENERATED "true")" ALL_SECRETS_GENERATED="$(/usr/local/bin/store_secret.sh save ALL-SECRETS-GENERATED "true")"
fi fi
# Wait (bounded: 360 x 5s = 30 min) until all 4 master nodes have published their private IPs
IP_WAIT_MAX_RETRIES=360 IP_WAIT_MAX_RETRIES=360
IP_WAIT_INTERVAL=5 IP_WAIT_INTERVAL=5
IP_WAIT_RETRIES=0 IP_WAIT_RETRIES=0
@ -421,7 +420,7 @@ while true; do
sleep $IP_WAIT_INTERVAL sleep $IP_WAIT_INTERVAL
done done
# Wait (bounded: 360 x 5s = 30 min) until master-node-1 has generated all shared secrets before fetching them # Wait until master-node-1 has generated all shared secrets before fetching them
SECRETS_WAIT_MAX_RETRIES=360 SECRETS_WAIT_MAX_RETRIES=360
SECRETS_WAIT_INTERVAL=5 SECRETS_WAIT_INTERVAL=5
SECRETS_WAIT_RETRIES=0 SECRETS_WAIT_RETRIES=0
@ -467,7 +466,7 @@ fi
ENABLED_MODULES=$(az keyvault secret show --vault-name ${keyVaultName} --name ENABLED-MODULES --query value -o tsv) ENABLED_MODULES=$(az keyvault secret show --vault-name ${keyVaultName} --name ENABLED-MODULES --query value -o tsv)
# Download the installer script (retry transient curl failures; fail if empty/missing) # Download first: sh <(curl ...) would silently run an empty script on a transient curl failure
INSTALLER_SCRIPT="/tmp/install_ov_master_node.sh" INSTALLER_SCRIPT="/tmp/install_ov_master_node.sh"
curl -fsSL --retry 8 --retry-all-errors --retry-delay 5 -o "$INSTALLER_SCRIPT" "http://get.openvidu.io/pro/ha/$OPENVIDU_VERSION/install_ov_master_node.sh" curl -fsSL --retry 8 --retry-all-errors --retry-delay 5 -o "$INSTALLER_SCRIPT" "http://get.openvidu.io/pro/ha/$OPENVIDU_VERSION/install_ov_master_node.sh"
if [ ! -s "$INSTALLER_SCRIPT" ]; then if [ ! -s "$INSTALLER_SCRIPT" ]; then
@ -1087,12 +1086,9 @@ systemctl start openvidu || { echo "[OpenVidu] error starting OpenVidu"; exit 1;
# Launch on reboot # Launch on reboot
echo "@reboot /usr/local/bin/restart.sh >> /var/log/openvidu-restart.log" 2>&1 | crontab echo "@reboot /usr/local/bin/restart.sh >> /var/log/openvidu-restart.log" 2>&1 | crontab
# Wait until this master node is healthy (check_app_ready.sh caps at 1200s). # check_app_ready.sh internally caps its wait at 1200s
# On failure exit WITHOUT publishing readiness, so media nodes keep waiting for another master.
/usr/local/bin/check_app_ready.sh || { echo "[OpenVidu] master node did not become healthy"; exit 1; } /usr/local/bin/check_app_ready.sh || { echo "[OpenVidu] master node did not become healthy"; exit 1; }
# Publish readiness so media nodes can start. Every healthy master writes the same value, so the
# first healthy master unblocks media and a failed master can no longer leave this unset (no SPOF).
az keyvault secret set --vault-name ${keyVaultName} --name FINISH-MASTER-NODE --value "true" az keyvault secret set --vault-name ${keyVaultName} --name FINISH-MASTER-NODE --value "true"
MASTER_NODE_NUM=${masterNodeNum} MASTER_NODE_NUM=${masterNodeNum}
@ -1295,8 +1291,7 @@ apt-get update && apt-get install -y \
# Get own private IP # Get own private IP
PRIVATE_IP=$(curl -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance/network/interface/0/ipv4/ipAddress/0/privateIpAddress?api-version=2017-08-01&format=text") PRIVATE_IP=$(curl -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance/network/interface/0/ipv4/ipAddress/0/privateIpAddress?api-version=2017-08-01&format=text")
# Gate 1: wait (bounded: 360 x 5s = 30 min) until master nodes generated the shared secrets and # Gate 1: wait for master secrets and IPs before installing
# published their 4 private IPs. This lets the heavy media installer run in parallel with the masters.
WAIT_INTERVAL=5 WAIT_INTERVAL=5
MAX_RETRIES=360 MAX_RETRIES=360
RETRIES=0 RETRIES=0
@ -1308,7 +1303,6 @@ while true; do
MASTER_NODE_3_PRIVATE_IP=$(az keyvault secret show --vault-name ${keyVaultName} --name MASTER-NODE-3-PRIVATE-IP --query value -o tsv 2>/dev/null) MASTER_NODE_3_PRIVATE_IP=$(az keyvault secret show --vault-name ${keyVaultName} --name MASTER-NODE-3-PRIVATE-IP --query value -o tsv 2>/dev/null)
MASTER_NODE_4_PRIVATE_IP=$(az keyvault secret show --vault-name ${keyVaultName} --name MASTER-NODE-4-PRIVATE-IP --query value -o tsv 2>/dev/null) MASTER_NODE_4_PRIVATE_IP=$(az keyvault secret show --vault-name ${keyVaultName} --name MASTER-NODE-4-PRIVATE-IP --query value -o tsv 2>/dev/null)
# Break once secrets are generated and all 4 master IPs are published
if [ "$ALL_SECRETS_GENERATED" == "true" ] && if [ "$ALL_SECRETS_GENERATED" == "true" ] &&
[ "$MASTER_NODE_1_PRIVATE_IP" != "" ] && [ "$MASTER_NODE_1_PRIVATE_IP" != "" ] &&
[ "$MASTER_NODE_2_PRIVATE_IP" != "" ] && [ "$MASTER_NODE_2_PRIVATE_IP" != "" ] &&
@ -1336,7 +1330,7 @@ REDIS_PASSWORD=$(az keyvault secret show --vault-name ${keyVaultName} --name RED
ENABLED_MODULES=$(az keyvault secret show --vault-name ${keyVaultName} --name ENABLED-MODULES --query value -o tsv) ENABLED_MODULES=$(az keyvault secret show --vault-name ${keyVaultName} --name ENABLED-MODULES --query value -o tsv)
OPENVIDU_VERSION=$(az keyvault secret show --vault-name ${keyVaultName} --name OPENVIDU-VERSION --query value -o tsv) OPENVIDU_VERSION=$(az keyvault secret show --vault-name ${keyVaultName} --name OPENVIDU-VERSION --query value -o tsv)
# Download the installer script (retry transient curl failures; fail if empty/missing) # Download first: sh <(curl ...) would silently run an empty script on a transient curl failure
INSTALLER_SCRIPT="/tmp/install_ov_media_node.sh" INSTALLER_SCRIPT="/tmp/install_ov_media_node.sh"
curl -fsSL --retry 8 --retry-all-errors --retry-delay 5 -o "$INSTALLER_SCRIPT" "http://get.openvidu.io/pro/ha/$OPENVIDU_VERSION/install_ov_media_node.sh" curl -fsSL --retry 8 --retry-all-errors --retry-delay 5 -o "$INSTALLER_SCRIPT" "http://get.openvidu.io/pro/ha/$OPENVIDU_VERSION/install_ov_media_node.sh"
if [ ! -s "$INSTALLER_SCRIPT" ]; then if [ ! -s "$INSTALLER_SCRIPT" ]; then
@ -1473,10 +1467,10 @@ az vmss update --resource-group $RESOURCE_GROUP_NAME --name $VM_SCALE_SET_NAME -
export HOME="/root" export HOME="/root"
# Install OpenVidu (heavy: docker + image pulls). Overlaps with the masters' own installs. # Install OpenVidu
/usr/local/bin/install.sh || { echo "[OpenVidu] error installing OpenVidu"; /usr/local/bin/delete_media_node.sh; } /usr/local/bin/install.sh || { echo "[OpenVidu] error installing OpenVidu"; /usr/local/bin/delete_media_node.sh; }
# Gate 2: wait (bounded: 360 x 5s = 30 min) for the master nodes to publish readiness before starting # Gate 2: wait for master readiness before starting
WAIT_INTERVAL=5 WAIT_INTERVAL=5
MAX_RETRIES=360 MAX_RETRIES=360
RETRIES=0 RETRIES=0

File diff suppressed because one or more lines are too long

View File

@ -314,8 +314,7 @@ locals {
is_c4a_instance = startswith(var.masterNodesInstanceType, "c4a-") is_c4a_instance = startswith(var.masterNodesInstanceType, "c4a-")
} }
# Default subnetwork the master instances live in (they use network = "default" with no # Must match the subnetwork the master instances implicitly use (network = "default", no explicit subnetwork)
# explicit subnetwork, so GCP places them in the auto-mode default subnetwork of the region)
data "google_compute_subnetwork" "default" { data "google_compute_subnetwork" "default" {
name = "default" name = "default"
region = var.region region = var.region
@ -323,9 +322,6 @@ data "google_compute_subnetwork" "default" {
depends_on = [google_project_service.compute_api] depends_on = [google_project_service.compute_api]
} }
# Static internal IPs for the master nodes. Reserving them up front lets the media instance
# template and every master receive the full list without waiting for the master instances to
# boot, which removes the runtime IP-exchange handshake through Secret Manager.
resource "google_compute_address" "master_internal_ip" { resource "google_compute_address" "master_internal_ip" {
count = 4 count = 4
name = lower("${var.stackName}-master-node-${count.index + 1}-internal-ip") name = lower("${var.stackName}-master-node-${count.index + 1}-internal-ip")
@ -337,8 +333,7 @@ resource "google_compute_address" "master_internal_ip" {
} }
locals { locals {
# Master node private IPs come from the reserved static internal addresses (index 0 -> master # Comma-separated: must match the installer's --master-node-private-ip-list format
# node 1, ...). Comma-separated to match the installer's --master-node-private-ip-list format.
master_node_private_ip_list = join(",", google_compute_address.master_internal_ip[*].address) master_node_private_ip_list = join(",", google_compute_address.master_internal_ip[*].address)
} }
@ -1018,7 +1013,6 @@ get_meta() { curl -s -H "Metadata-Flavor: Google" "$${METADATA_URL}/$1"; }
# Get master node number from metadata # Get master node number from metadata
MASTER_NODE_NUM=$(get_meta "instance/attributes/masterNodeNum") MASTER_NODE_NUM=$(get_meta "instance/attributes/masterNodeNum")
# Get the list of master node private IPs (static internal IPs passed via metadata)
MASTER_NODE_PRIVATE_IP_LIST=$(get_meta "instance/attributes/masterNodePrivateIPList") MASTER_NODE_PRIVATE_IP_LIST=$(get_meta "instance/attributes/masterNodePrivateIPList")
# Check if secrets have been generated # Check if secrets have been generated
@ -1080,7 +1074,6 @@ if [[ $MASTER_NODE_NUM -eq 1 ]] && [[ "$ALL_SECRETS_GENERATED" == "false" ]]; th
fi fi
# Wait for master-1 to finish generating all shared secrets before reading them. # Wait for master-1 to finish generating all shared secrets before reading them.
# Bounded to 360 iterations x 5s = 30 minutes.
i=0 i=0
while ! gcloud secrets versions access latest --secret=ALL_SECRETS_GENERATED 2>/dev/null | grep -q "true"; do while ! gcloud secrets versions access latest --secret=ALL_SECRETS_GENERATED 2>/dev/null | grep -q "true"; do
i=$((i + 1)) i=$((i + 1))
@ -1115,8 +1108,7 @@ LIVEKIT_API_KEY=$(gcloud secrets versions access latest --secret=LIVEKIT_API_KEY
LIVEKIT_API_SECRET=$(gcloud secrets versions access latest --secret=LIVEKIT_API_SECRET) LIVEKIT_API_SECRET=$(gcloud secrets versions access latest --secret=LIVEKIT_API_SECRET)
ENABLED_MODULES=$(gcloud secrets versions access latest --secret=ENABLED_MODULES) ENABLED_MODULES=$(gcloud secrets versions access latest --secret=ENABLED_MODULES)
# Build install command. Download the installer to a file first: process substitution # Download first: sh <(curl ...) would silently run an empty script on a transient curl failure
# (sh <(curl ...)) would silently run an empty script and exit 0 on a transient curl failure.
INSTALLER_SCRIPT="/tmp/install_ov_master_node.sh" INSTALLER_SCRIPT="/tmp/install_ov_master_node.sh"
curl -fsSL --retry 8 --retry-all-errors --retry-delay 5 -o "$INSTALLER_SCRIPT" "http://get.openvidu.io/pro/ha/$OPENVIDU_VERSION/install_ov_master_node.sh" curl -fsSL --retry 8 --retry-all-errors --retry-delay 5 -o "$INSTALLER_SCRIPT" "http://get.openvidu.io/pro/ha/$OPENVIDU_VERSION/install_ov_master_node.sh"
if [ ! -s "$INSTALLER_SCRIPT" ]; then if [ ! -s "$INSTALLER_SCRIPT" ]; then
@ -1474,7 +1466,6 @@ EOF
check_app_ready_script = <<-EOF check_app_ready_script = <<-EOF
#!/bin/bash #!/bin/bash
# Bounded to 240 iterations x 5s = 20 minutes.
i=0 i=0
while true; do while true; do
HTTP_STATUS=$(curl -Ik http://localhost:7880/health/caddy 2>/dev/null | head -n1 | awk '{print $2}') HTTP_STATUS=$(curl -Ik http://localhost:7880/health/caddy 2>/dev/null | head -n1 | awk '{print $2}')
@ -1624,7 +1615,6 @@ STACK_NAME=$(get_meta "instance/attributes/stackName")
PRIVATE_IP=$(get_meta "instance/network-interfaces/0/ip") PRIVATE_IP=$(get_meta "instance/network-interfaces/0/ip")
# Wait for master nodes to be ready by checking secrets. # Wait for master nodes to be ready by checking secrets.
# Bounded to 180 iterations x 10s = 30 minutes.
i=0 i=0
while ! gcloud secrets versions access latest --secret=ALL_SECRETS_GENERATED 2>/dev/null | grep -q "true"; do while ! gcloud secrets versions access latest --secret=ALL_SECRETS_GENERATED 2>/dev/null | grep -q "true"; do
i=$((i + 1)) i=$((i + 1))
@ -1649,9 +1639,7 @@ if [[ "$OPENVIDU_VERSION" == "none" ]]; then
exit 1 exit 1
fi fi
# Build install command for media node. Download the installer to a file first: process # Download first: sh <(curl ...) would silently run an empty script on a transient curl failure
# substitution (sh <(curl ...)) would silently run an empty script and exit 0 on a transient
# curl failure.
INSTALLER_SCRIPT="/tmp/install_ov_media_node.sh" INSTALLER_SCRIPT="/tmp/install_ov_media_node.sh"
curl -fsSL --retry 8 --retry-all-errors --retry-delay 5 -o "$INSTALLER_SCRIPT" "http://get.openvidu.io/pro/ha/$OPENVIDU_VERSION/install_ov_media_node.sh" curl -fsSL --retry 8 --retry-all-errors --retry-delay 5 -o "$INSTALLER_SCRIPT" "http://get.openvidu.io/pro/ha/$OPENVIDU_VERSION/install_ov_media_node.sh"
if [ ! -s "$INSTALLER_SCRIPT" ]; then if [ ! -s "$INSTALLER_SCRIPT" ]; then