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

feat(cd): add external static IPs to release nodes #8891

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
46 changes: 39 additions & 7 deletions .github/workflows/cd-deploy-nodes-gcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,6 @@
needs: [ build, versioning, test-configuration-file, test-zebra-conf-path, get-disk-name ]
runs-on: ubuntu-latest
timeout-minutes: 60
env:
CACHED_DISK_NAME: ${{ needs.get-disk-name.outputs.cached_disk_name }}
permissions:
contents: 'read'
id-token: 'write'
Expand All @@ -256,14 +254,17 @@

# Makes the Zcash network name lowercase.
#
# Labels in GCP are required to be in lowercase, but the blockchain network
# uses sentence case, so we need to downcase the network.
# Labels and disks in GCP are required to be in lowercase, but the blockchain network
# uses sentence case, so we need to downcase the ${{ matrix.network }}.
#
# Passes the lowercase network to subsequent steps using $NETWORK env variable.
# Passes ${{ matrix.network }} to subsequent steps using $NETWORK env variable.
# Passes ${{ env.GITHUB_REF_SLUG_URL }} to subsequent steps using $SHORT_GITHUB_REF env variable.
- name: Downcase network name for labels
run: |
NETWORK_CAPS="${{ matrix.network }}"
echo "NETWORK=${NETWORK_CAPS,,}" >> "$GITHUB_ENV"
LONG_GITHUB_REF="${{ env.GITHUB_REF_SLUG_URL }}"
echo "SHORT_GITHUB_REF=${LONG_GITHUB_REF:0:12}" >> "$GITHUB_ENV"

# Setup gcloud CLI
- name: Authenticate to Google Cloud
Expand All @@ -276,8 +277,37 @@
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2.1.2

# TODO: The sub-find-cached-disks.yml reusable workflow does not supports matrix strategy
# We need to find a way to pass the matching network from the `get-disk-name` job
# In the meanwhile we're repeating the logic of sub-find-cached-disks.yml here
- name: Check if cached state disks exists
id: get-available-disks
env:
GITHUB_REF: ${{ env.SHORT_GITHUB_REF }}
NETWORK: ${{ env.NETWORK }} # use lowercase version from env, not input
DISK_PREFIX: zebrad-cache
DISK_SUFFIX: ${{ inputs.cached_disk_type || 'tip' }}
PREFER_MAIN_CACHED_STATE: ${{ inputs.prefer_main_cached_state }}
run: |

Check warning on line 291 in .github/workflows/cd-deploy-nodes-gcp.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/cd-deploy-nodes-gcp.yml#L291

shellcheck reported issue in this script: SC2129:style:2:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects [shellcheck]
Raw output
.github/workflows/cd-deploy-nodes-gcp.yml:291:9: shellcheck reported issue in this script: SC2129:style:2:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects [shellcheck]
source ./.github/workflows/scripts/gcp-get-cached-disks.sh
echo "state_version=${LOCAL_STATE_VERSION}" >> "${GITHUB_OUTPUT}"
echo "cached_disk_name=${CACHED_DISK_NAME}" >> "${GITHUB_OUTPUT}"
echo "lwd_tip_disk=${LWD_TIP_DISK}" >> "${GITHUB_OUTPUT}"
echo "zebra_tip_disk=${ZEBRA_TIP_DISK}" >> "${GITHUB_OUTPUT}"
echo "zebra_checkpoint_disk=${ZEBRA_CHECKPOINT_DISK}" >> "${GITHUB_OUTPUT}"

- name: Get IP address for long-running release nodes
if: ${{ github.event_name == 'release' }}
run: echo "IP_ADDRESS=$(gcloud compute addresses describe zebra-${NETWORK} --region ${{ vars.GCP_REGION }} --format='value(address)')" >> "$GITHUB_ENV"

Check warning on line 301 in .github/workflows/cd-deploy-nodes-gcp.yml

View workflow job for this annotation

GitHub Actions / actionlint

[actionlint] .github/workflows/cd-deploy-nodes-gcp.yml#L301

shellcheck reported issue in this script: SC2086:info:1:60: Double quote to prevent globbing and word splitting [shellcheck]
Raw output
.github/workflows/cd-deploy-nodes-gcp.yml:301:9: shellcheck reported issue in this script: SC2086:info:1:60: Double quote to prevent globbing and word splitting [shellcheck]

- name: Create instance template for ${{ matrix.network }}
run: |
if [ -n "${{ env.IP_ADDRESS }}" ]; then
IP_FLAG="--address=${{ env.IP_ADDRESS }}"
else
IP_FLAG=""
fi

DISK_NAME="zebrad-cache-${{ env.GITHUB_HEAD_REF_SLUG_URL || env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}-${NETWORK}"
DISK_PARAMS="name=${DISK_NAME},device-name=${DISK_NAME},size=400GB,type=pd-balanced"
if [ -n "${{ env.CACHED_DISK_NAME }}" ]; then
Expand All @@ -288,13 +318,15 @@
echo "No cached disk found for ${{ matrix.network }} in main branch"
exit 1
fi

gcloud compute instance-templates create-with-container zebrad-${{ needs.versioning.outputs.major_version || env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}-${NETWORK} \
--machine-type ${{ vars.GCP_SMALL_MACHINE }} \
--boot-disk-size=10GB \
--boot-disk-type=pd-standard \
--image-project=cos-cloud \
--image-family=cos-stable \
--network-interface=subnet=${{ vars.GCP_SUBNETWORK }} \
--subnet=${{ vars.GCP_SUBNETWORK }} \
${IP_FLAG} \
--create-disk="${DISK_PARAMS}" \
--container-mount-disk=mount-path='/var/cache/zebrad-cache',name=${DISK_NAME},mode=rw \
--container-stdin \
Expand Down Expand Up @@ -406,7 +438,7 @@
--boot-disk-type=pd-standard \
--image-project=cos-cloud \
--image-family=cos-stable \
--network-interface=subnet=${{ vars.GCP_SUBNETWORK }} \
--subnet=${{ vars.GCP_SUBNETWORK }} \
--create-disk="${DISK_PARAMS}" \
--container-mount-disk=mount-path='/var/cache/zebrad-cache',name=${DISK_NAME},mode=rw \
--container-stdin \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/manual-zcashd-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
--container-image electriccoinco/zcashd \
--container-env ZCASHD_NETWORK="${{ inputs.network }}" \
--machine-type ${{ vars.GCP_SMALL_MACHINE }} \
--network-interface=subnet=${{ vars.GCP_SUBNETWORK }} \
--subnet=${{ vars.GCP_SUBNETWORK }} \
--service-account ${{ vars.GCP_DEPLOYMENTS_SA }} \
--scopes cloud-platform \
--labels=app=zcashd,environment=prod,network=${NETWORK},github_ref=${{ env.GITHUB_REF_SLUG_URL }} \
Expand Down
Loading