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

chore: shutdown script for instance template deployments #1852

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,10 @@ deploy.staging.versioned:
--region=europe-west1 \
--gcs-log-dir="gs://logflare-staging_cloudbuild-logs/logs"

gcloud builds submit \
--no-source \
gcloud builds submit . \
--config=./cloudbuild/staging/deploy.yaml \
--substitutions=_IMAGE_TAG=$(VERSION),_NORMALIZED_IMAGE_TAG=$(NORMALIZED_VERSION),_INSTANCE_TYPE=c2d-standard-2,_CLUSTER=versioned \
--region=us-central1 \
--region=us-west1 \
--gcs-log-dir="gs://logflare-staging_cloudbuild-logs/logs"


Expand All @@ -158,8 +157,7 @@ deploy.prod.versioned:
--region=europe-west3 \
--gcs-log-dir="gs://logflare-prod_cloudbuild-logs/logs"

gcloud builds submit \
--no-source \
gcloud builds submit . \
--config=./cloudbuild/prod/pre-deploy.yaml \
--substitutions=_IMAGE_TAG=$(VERSION),_NORMALIZED_IMAGE_TAG=$(NORMALIZED_VERSION) \
--region=europe-west3 \
Expand Down
1 change: 1 addition & 0 deletions cloudbuild/prod/pre-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ steps:
- --service-account=compute-engine-2022@logflare-232118.iam.gserviceaccount.com
- --scopes=https://www.googleapis.com/auth/cloud-platform
- --tags=phoenix-http,https-server
- --metadata-from-file=shutdown-script=./cloudbuild/shutdown.sh
- --container-image=${_CONTAINER_IMAGE}
- --container-privileged
- --container-restart-policy=always
Expand Down
24 changes: 24 additions & 0 deletions cloudbuild/shutdown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# echo $PWD

NODE_IP=$(curl \
-s "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip" \
-H "Metadata-Flavor: Google")

NODE=logflare@$NODE_IP

echo "Stopping node $NODE"

curl -X "POST" "https://api.logflarestaging.com/api/logs?source=$LOGFLARE_LOGGER_BACKEND_SOURCE_ID" \
-H 'Content-Type: application/json' \
-H 'X-API-KEY: $LOGFLARE_LOGGER_BACKEND_API_KEY' \
-d $'{
"message": "Stopping node $NODE"
}'

curl -X "PUT" "http://localhost:4000/admin/shutdown?code=$LOGFLARE_NODE_SHUTDOWN_CODE"

sleep 20

echo "Stopped node $NODE"
1 change: 1 addition & 0 deletions cloudbuild/staging/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ steps:
- --scopes=https://www.googleapis.com/auth/cloud-platform
- --tags=phoenix-http,https-server
- --container-image=${_CONTAINER_IMAGE}
- --metadata-from-file=shutdown-script=./cloudbuild/shutdown.sh
- --container-privileged
- --container-restart-policy=always
- --container-env=LOGFLARE_GRPC_PORT=4001,LOGFLARE_MIN_CLUSTER_SIZE=1,OVERRIDE_MAGIC_COOKIE=${_COOKIE}
Expand Down