diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dde20237182e..027974a9e895 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,45 +126,83 @@ jobs: runs-on: ubuntu-latest if: github.ref == 'refs/heads/dev-upgrade' && !startsWith(github.ref, 'refs/tags/') needs: devnet_build_push + concurrency: + group: devnet-k8-apply + cancel-in-progress: false steps: - uses: actions/checkout@v4 - name: Set up kubectl uses: azure/setup-kubectl@v4 with: version: "v1.19.11" - - name: Apply new image version to Kubernetes deployments + - name: Apply new image version to Kubernetes deployments in batches run: | mkdir -p $HOME/.kube echo "${{ secrets.KUBE_CONFIG }}" | base64 --decode > $HOME/.kube/config chmod 600 $HOME/.kube/config + git_hash=$(git rev-parse --short "$GITHUB_SHA") - masternodes=$(kubectl get deployment -o json | jq -r '.items[] | select(.metadata.name | test("^masternode[0-9]")) | .metadata.name' | sort) - rpcs=$(kubectl get deployment -o json| jq -r '.items[] | select(.metadata.name | test("rpc")) | "\(.metadata.name)"') - echo "Masternodes: $masternodes" - echo "RPCs: $rpcs" + image="xinfinorg/devnet:dev-upgrade-${git_hash}" - # Skip masternode1 through masternode25, update the rest. + # Sort masternodes numerically by the trailing number (handles masternode1..masternode125) + masternodes=$(kubectl get deployment -o json \ + | jq -r '.items[] | select(.metadata.name | test("^masternode[0-9]")) | .metadata.name' \ + | sort -V) readarray -t mn_array <<< "$masternodes" total=${#mn_array[@]} - echo "Total masternode deployments: $total, skipping masternode1..masternode25" - - for name in "${mn_array[@]}"; do - if [[ $name =~ ^masternode[0-9] ]]; then - num=${name#masternode} - num=${num%%-*} - if [[ $num =~ ^[0-9]+$ ]] && (( num >= 1 && num <= 25 )); then - echo "Skipping deployment: $name" - continue - fi - fi + echo "Total masternode deployments: $total" - echo "Updating deployment: $name" - kubectl set image "deployment/$name" "$name=xinfinorg/devnet:dev-upgrade-${git_hash}" || true - done + BATCH_SIZE=25 + batch_num=0 + + for (( start=0; start total )) && end=$total + echo "=== Batch ${batch_num}: nodes $((start+1))–${end} ===" + + batch_names=() + for (( i=start; i