From 17d36ffc7a4efa521f76771db22824aba2f3d475 Mon Sep 17 00:00:00 2001 From: Gustavo Valverde Date: Fri, 9 Jun 2023 15:16:39 -0400 Subject: [PATCH] fix(deploy): allow the container to raise in MIGs (#6893) * fix(deploy): allow the container to raise in MIGs * fix(docker): add the `ZEBRA_CACHED_STATE_DIR` as a default `ENV` This no longer requires the env variable to be defined in other places, unless we're changing the default configuration --- .github/workflows/continous-delivery.yml | 16 +++++++++------- docker/Dockerfile | 4 ++++ docker/runtime-entrypoint.sh | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/continous-delivery.yml b/.github/workflows/continous-delivery.yml index 1359e5004..e33c76b9f 100644 --- a/.github/workflows/continous-delivery.yml +++ b/.github/workflows/continous-delivery.yml @@ -212,15 +212,18 @@ jobs: - name: Create instance template for ${{ matrix.network }} run: | gcloud compute instance-templates create-with-container zebrad-${{ needs.versioning.outputs.major_version || env.GITHUB_REF_SLUG_URL }}-${{ env.GITHUB_SHA_SHORT }}-${NETWORK} \ + --boot-disk-size 300GB \ --boot-disk-type=pd-ssd \ --image-project=cos-cloud \ --image-family=cos-stable \ --user-output-enabled \ - --metadata google-logging-enabled=true,google-logging-use-fluentbit=true \ + --metadata google-logging-enabled=true,google-logging-use-fluentbit=true,google-monitoring-enabled=true \ + --container-stdin \ + --container-tty \ --container-image ${{ vars.GAR_BASE }}/zebrad@${{ needs.build.outputs.image_digest }} \ --container-env "NETWORK=${{ matrix.network }},LOG_FILE=${{ vars.CD_LOG_FILE }},LOG_COLOR=false,SENTRY_DSN=${{ vars.SENTRY_DSN }},SHORT_SHA=${{ env.GITHUB_SHA_SHORT }}" \ - --create-disk=name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK},auto-delete=yes,size=300GB,type=pd-ssd \ - --container-mount-disk=mount-path="/zebrad-cache",name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK} \ + --create-disk=name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK},device-name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK},auto-delete=yes,size=300GB,type=pd-ssd,mode=rw \ + --container-mount-disk=mount-path='/var/cache/zebrad-cache',name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK},mode=rw \ --machine-type ${{ vars.GCP_SMALL_MACHINE }} \ --network-interface=subnet=${{ vars.GCP_SUBNETWORK }} \ --service-account ${{ vars.GCP_DEPLOYMENTS_SA }} \ @@ -315,14 +318,13 @@ jobs: --image-project=cos-cloud \ --image-family=cos-stable \ --user-output-enabled \ - --metadata google-logging-enabled=true,google-logging-use-fluentbit=true \ + --metadata google-logging-enabled=true,google-logging-use-fluentbit=true,google-monitoring-enabled=true \ --container-stdin \ --container-tty \ --container-image ${{ vars.GAR_BASE }}/zebrad@${{ needs.build.outputs.image_digest }} \ --container-env "NETWORK=${{ inputs.network }},LOG_FILE=${{ inputs.log_file }},LOG_COLOR=false,SENTRY_DSN=${{ vars.SENTRY_DSN }},SHORT_SHA=${{ env.GITHUB_SHA_SHORT }}" \ - --create-disk=auto-delete=yes,size=300GB,type=pd-ssd \ - --create-disk=name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK},auto-delete=yes,size=300GB,type=pd-ssd \ - --container-mount-disk=mount-path='/zebrad-cache',name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK} \ + --create-disk=name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK},device-name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK},auto-delete=yes,size=300GB,type=pd-ssd,mode=rw \ + --container-mount-disk=mount-path='/var/cache/zebrad-cache',name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK},mode=rw \ --machine-type ${{ vars.GCP_SMALL_MACHINE }} \ --network-interface=subnet=${{ vars.GCP_SUBNETWORK }} \ --service-account ${{ vars.GCP_DEPLOYMENTS_SA }} \ diff --git a/docker/Dockerfile b/docker/Dockerfile index f0f4ae52f..36c6751b4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -162,6 +162,10 @@ ENV RPC_PORT ${RPC_PORT} ARG LOG_FILE ENV LOG_FILE ${LOG_FILE} +# Set this to change the default cached state directory +ARG ZEBRA_CACHED_STATE_DIR +ENV ZEBRA_CACHED_STATE_DIR ${ZEBRA_CACHED_STATE_DIR:-/var/cache/zebrad-cache} + # Zebra automatically detects if it is attached to a terminal, and uses colored output. # Set this to 'true' to force using color even if the output is not a terminal. # Set this to 'false' to disable using color even if the output is a terminal. diff --git a/docker/runtime-entrypoint.sh b/docker/runtime-entrypoint.sh index fbac0849e..98b1c9447 100755 --- a/docker/runtime-entrypoint.sh +++ b/docker/runtime-entrypoint.sh @@ -40,7 +40,7 @@ network = "$NETWORK" listen_addr = "0.0.0.0" [state] -cache_dir = "/zebrad-cache" +cache_dir = "$ZEBRA_CACHED_STATE_DIR" [metrics] #endpoint_addr = "0.0.0.0:9999"