state: replication: raft: tweak chunk size & promo timeout #128
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- 'staging' | |
- 'dev' | |
- 'testnet' | |
- 'mainnet' | |
name: Upgrade Relayer Clusters | |
jobs: | |
build-and-push-ecr: | |
runs-on: buildjet-16vcpu-ubuntu-2204-arm | |
outputs: | |
image: ${{ steps.login-ecr.outputs.registry }}/relayer-${{ github.ref_name }}:${{ github.sha }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: "us-east-2" | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Set up Docker BuildX | |
uses: docker/setup-buildx-action@v3 | |
- name: Build, tag, and push image to Amazon ECR | |
id: docker-build-push | |
uses: docker/build-push-action@v5 | |
env: | |
IMAGE: ${{ steps.login-ecr.outputs.registry }}/relayer-${{ github.ref_name }} | |
CARGO_FEATURES: ${{ github.ref_name == 'dev' && 'dev-metrics' || 'default' }} | |
with: | |
platforms: linux/arm64 | |
context: . | |
file: ./docker/release/Dockerfile | |
build-args: | | |
CARGO_FEATURES=${{ env.CARGO_FEATURES }} | |
push: true | |
tags: ${{ env.IMAGE }}:${{ github.sha }},${{ env.IMAGE }}:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
setup-cluster-names: | |
runs-on: ubuntu-latest | |
outputs: | |
cluster_names: ${{ steps.gen-cluster-names.outputs.cluster_names }} | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- id: gen-cluster-names | |
run: >- | |
if [[ "${{ github.ref_name }}" == "staging" ]]; then | |
NUM_CLUSTERS=${{ vars.NUM_CLUSTERS_STAGING }} | |
NUM_SINGLENODE_CLUSTERS=${{ vars.NUM_SINGLENODE_CLUSTERS_STAGING }} | |
elif [[ "${{ github.ref_name }}" == "dev" ]]; then | |
NUM_CLUSTERS=${{ vars.NUM_CLUSTERS_DEV }} | |
NUM_SINGLENODE_CLUSTERS=${{ vars.NUM_SINGLENODE_CLUSTERS_DEV }} | |
elif [[ "${{ github.ref_name }}" == "testnet" ]]; then | |
NUM_CLUSTERS=${{ vars.NUM_CLUSTERS_TESTNET }} | |
NUM_SINGLENODE_CLUSTERS=${{ vars.NUM_SINGLENODE_CLUSTERS_TESTNET }} | |
elif [[ "${{ github.ref_name }}" == "mainnet" ]]; then | |
NUM_CLUSTERS=${{ vars.NUM_CLUSTERS_MAINNET }} | |
NUM_SINGLENODE_CLUSTERS=${{ vars.NUM_SINGLENODE_CLUSTERS_MAINNET }} | |
else | |
echo "Unsupported branch. Defaulting to 1 cluster." | |
NUM_CLUSTERS=1 | |
NUM_SINGLENODE_CLUSTERS=0 | |
fi | |
names=$(python -c "import json; | |
cluster_names = [ \"${{ github.ref_name }}-cluster\" + str(i) for i in range($NUM_CLUSTERS)]; | |
cluster_names.extend([ \"${{ github.ref_name }}-sn-cluster\" + str(i) for i in range($NUM_SINGLENODE_CLUSTERS)]); | |
print(json.dumps(cluster_names))") | |
echo "cluster_names={ \"cluster\": $names }" >> $GITHUB_OUTPUT | |
upgrade-relayer-clusters: | |
runs-on: ubuntu-latest | |
needs: [build-and-push-ecr, setup-cluster-names] | |
strategy: | |
matrix: ${{fromJson(needs.setup-cluster-names.outputs.cluster_names)}} | |
steps: | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: "us-east-2" | |
- name: Get the existing task definitions | |
id: fetch-task-def | |
run: | | |
aws ecs describe-task-definition --task-definition "${{ matrix.cluster }}-task-def" --query 'taskDefinition' > task-definition.json | |
- name: Fill in the new image ID in the Amazon ECS task definition | |
id: update-task-def | |
uses: aws-actions/amazon-ecs-render-task-definition@v1 | |
with: | |
task-definition: task-definition.json | |
container-name: relayer-node | |
image: ${{ needs.build-and-push-ecr.outputs.image }} | |
- name: Deploy Amazon ECS task definition | |
id: ecs-deploy | |
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | |
with: | |
task-definition: ${{ steps.update-task-def.outputs.task-definition }} | |
service: ${{ matrix.cluster }}-service | |
cluster: ${{ matrix.cluster }} | |
wait-for-service-stability: true | |
- name: Check for rollback | |
id: check-rollback | |
run: | | |
CURRENT_TASK_DEF_ARN=$(aws ecs describe-services --cluster ${{ matrix.cluster }} --services ${{ matrix.cluster }}-service --query services[0].deployments[0].taskDefinition | jq -r ".") | |
NEW_TASK_DEF_ARN=${{ steps.ecs-deploy.outputs.task-definition-arn }} | |
if [ "$CURRENT_TASK_DEF_ARN" != "$NEW_TASK_DEF_ARN" ]; then | |
echo "Deployment rolled back." | |
exit 1 | |
fi |