Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: update protonet reset workflow for new infra #2033

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 0 additions & 54 deletions .github/workflows/cd-protonet-manual.yml

This file was deleted.

50 changes: 18 additions & 32 deletions .github/workflows/cd-protonet.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,26 @@
name: Continuous Deployment (Protonet)
## run after every successful CI job of new commits to the master branch
#on:
# workflow_run:
# workflows: [Continuous Integration (Kava Master)]
# types:
# - completed

jobs:
# in order:
# enter standby (prevents autoscaling group from killing node during deploy)
# stop kava
# take ebs + zfs snapshots
# download updated binary and genesis
# reset application database state (only done on internal testnet)
reset-chain-to-zero-state:
# only start cd pipeline if last ci run was successful
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: ./.github/workflows/cd-reset-internal-testnet.yml
with:
aws-region: us-east-1
chain-id: proto_2221-17000
ssm-document-name: kava-testnet-internal-node-update
playbook-name: reset-protonet-playbook.yml
playbook-infrastructure-branch: master
secrets: inherit
## run after every successful CI job of new commits to the master branch, or on manual dispatch
on:
workflow_run:
workflows: [Continuous Integration (Kava Master)]
types:
- completed
workflow_dispatch:
Comment on lines +4 to +9
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this workflow supports being triggered by either:

  1. a successful run of the CI on merge to master
  2. manual dispatch via the github UI

configuring it this way allows us to have a single file instead of two copies with different on conditions


# start kava with new binary and genesis state on api, peer and seed nodes, place nodes in service once they start and are synched to live
start-chain-api:
uses: ./.github/workflows/cd-start-chain.yml
jobs:
reset-and-restart-chain:
# only start cd pipeline if last ci run was successful (or it this is being manually dispatched)
if: |
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
uses: ./.github/workflows/cd-reset-network.yml
with:
aws-region: us-east-1
chain-id: proto_2221-17000
ssm-document-name: kava-testnet-internal-node-update
playbook-name: start-chain-api-playbook.yml
ssm-document-name: kava-protonet-api-instance-update
playbook-infrastructure-branch: master
secrets: inherit
needs: [reset-chain-to-zero-state]

# setup test and development accounts and balances, deploy contracts by calling the chain's api
seed-chain-state:
Expand All @@ -46,9 +31,10 @@ jobs:
seed-script-filename: seed-protonet.sh
erc20-deployer-network-name: protonet
genesis_validator_addresses: "kavavaloper14w4avgdvqrlpww6l5dhgj4egfn6ln7gmtp7r2m"
kava_version_filepath: ./ci/env/kava-protonet/KAVA.VERSION
kava_version_filepath: ./ci/env/kava-protonet/KAVA.VERSION
secrets: inherit
needs: [start-chain-api]
needs: [reset-and-restart-chain]

post-pipeline-metrics:
uses: ./.github/workflows/metric-pipeline.yml
if: always() # always run so we metric failures and successes
Expand Down
99 changes: 99 additions & 0 deletions .github/workflows/cd-reset-network.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# for use with ephemeral testnets like internal testnet

name: Reset Ephemeral Network
on:
workflow_call:
inputs:
chain-id:
required: true
type: string
aws-region:
required: true
type: string
ssm-document-name:
required: true
type: string
playbook-infrastructure-branch:
required: true
type: string
secrets:
CI_AWS_KEY_ID:
required: true
CI_AWS_KEY_SECRET:
required: true
KAVA_PRIVATE_GITHUB_ACCESS_TOKEN:
required: true
jobs:
reset-ephemeral-network:
runs-on: ubuntu-latest
steps:
- name: checkout infrastructure repo
uses: actions/checkout@v4
with:
repository: Kava-Labs/infrastructure
token: ${{ secrets.KAVA_PRIVATE_GITHUB_ACCESS_TOKEN }}
path: infrastructure
ref: master

- name: Set up Go with kava-node-updater cache
uses: actions/setup-go@v5
with:
go-version-file: infrastructure/cli/kava-node-updater/go.mod
cache-dependency-path: infrastructure/cli/kava-node-updater/go.mod

- name: build kava node updater
run: cd infrastructure/cli/kava-node-updater && make install && cd ../../../

- name: stop chain services & reset data on all chain nodes
run: |
echo $AWS_REGION $CHAIN_ID $SSM_DOCUMENT_NAME $AWS_SDK_LOAD_CONFIG $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY
env:
SSM_DOCUMENT_NAME: ${{ inputs.ssm-document-name }}
CHAIN_ID: ${{ inputs.chain-id }}
AWS_SDK_LOAD_CONFIG: 1
AWS_REGION: ${{ inputs.aws-region }}
AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_KEY_SECRET }}
PLAYBOOK_INFRASTRUCTURE_BRANCH: ${{ inputs.playbook-infrastructure-branch }}

- name: stop chain services & reset data on all chain nodes
run: |
kava-node-updater \
--debug \
--max-retries=2 \
--aws-ssm-document-name=$SSM_DOCUMENT_NAME \
--infrastructure-git-pointer=$PLAYBOOK_INFRASTRUCTURE_BRANCH \
--chain-id=$CHAIN_ID \
--max-upgrade-batch-size=0 \
--wait-for-node-sync-after-upgrade=false \
--update-playbook-filename=reset-chain-data.yml
env:
SSM_DOCUMENT_NAME: ${{ inputs.ssm-document-name }}
CHAIN_ID: ${{ inputs.chain-id }}
AWS_SDK_LOAD_CONFIG: 1
AWS_REGION: ${{ inputs.aws-region }}
AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_KEY_SECRET }}
PLAYBOOK_INFRASTRUCTURE_BRANCH: ${{ inputs.playbook-infrastructure-branch }}

# NOTE: we wait for the reset to finish before restarting the nodes to prevent nodes from
# re-syncing the previous chain state.
- name: reconfigure & restart chain services on all chain nodes
run: |
kava-node-updater \
--debug \
--max-retries=2 \
--aws-ssm-document-name=$SSM_DOCUMENT_NAME \
--infrastructure-git-pointer=$PLAYBOOK_INFRASTRUCTURE_BRANCH \
--chain-id=$CHAIN_ID \
--max-upgrade-batch-size=0 \
--wait-for-node-sync-after-upgrade=false \
--update-playbook-filename=playbook.yml
env:
SSM_DOCUMENT_NAME: ${{ inputs.ssm-document-name }}
CHAIN_ID: ${{ inputs.chain-id }}
AWS_REGION: ${{ inputs.aws-region }}
AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_KEY_SECRET }}
AWS_SDK_LOAD_CONFIG: 1
PLAYBOOK_INFRASTRUCTURE_BRANCH: ${{ inputs.playbook-infrastructure-branch }}
Loading