e2e: fix collection of boot logs on GCP (#401)

Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
Paul Meyer 2022-10-31 10:40:08 +01:00 committed by GitHub
parent fd74ef754e
commit 4cd659b394
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 11 deletions

View File

@ -179,10 +179,7 @@ runs:
./.github/actions/constellation_create/az-logs.sh ${AZURE_RESOURCE_GROUP}
;;
gcp)
CONTROL_NODES=$(jq -r '.gcpcontrolplaneinstancegroup' constellation-state.json)
WORKER_NODES=$(jq -r '.gcpworkerinstancegroup' constellation-state.json)
ZONE=$(jq -r '.gcpzone' constellation-state.json)
./.github/actions/constellation_create/gcp-logs.sh ${CONTROL_NODES} ${WORKER_NODES} ${ZONE}
./.github/actions/constellation_create/gcp-logs.sh
;;
esac
echo "::endgroup::"

View File

@ -1,18 +1,26 @@
#!/usr/bin/env bash
# Usage: ./gcp-logs.sh <control-instance-group-name> <worker-instance-group-name> <zone>
# Usage: ./gcp-logs.sh
CONTROL_INSTANCE_GROUP=$(terraform show -json | jq -r .'values.root_module.child_modules[] | select(.address == "module.instance_group_control_plane") | .resources[0].values.base_instance_name' )
WORKER_INSTANCE_GROUP=$(terraform show -json | jq -r .'values.root_module.child_modules[] | select(.address == "module.instance_group_worker") | .resources[0].values.base_instance_name')
ZONE=$(terraform show -json | jq -r .'values.root_module.child_modules[] | select(.address == "module.instance_group_control_plane") | .resources[0].values.zone' )
CONTROL_INSTANCE_GROUP_SHORT=${CONTROL_INSTANCE_GROUP##*/}
WORKER_INSTANCE_GROUP_SHORT=${WORKER_INSTANCE_GROUP##*/}
CONTROL_INSTANCES=$(gcloud compute instance-groups managed list-instances ${CONTROL_INSTANCE_GROUP_SHORT} --zone ${ZONE} --format=json | jq -r '.[] | .instance')
WORKER_INSTANCES=$(gcloud compute instance-groups managed list-instances ${WORKER_INSTANCE_GROUP_SHORT} --zone ${ZONE} --format=json | jq -r '.[] | .instance')
CONTROL_INSTANCES=$(gcloud compute instance-groups list-instances $1 --zone $3 --format=json | jq -r .'[] | .instance')
WORKER_INSTANCES=$(gcloud compute instance-groups list-instances $2 --zone $3 --format=json | jq -r .'[] | .instance')
ALL_INSTANCES="$CONTROL_INSTANCES $WORKER_INSTANCES"
printf "Fetching logs for %s and %s\n" $CONTROL_INSTANCES $WORKER_INSTANCES
printf "Fetching logs for %s and %s\n" ${CONTROL_INSTANCES} ${WORKER_INSTANCES}
for INSTANCE in $ALL_INSTANCES; do
SHORT_NAME=${INSTANCE##*/}
printf "Fetching for %s\n" $SHORT_NAME
gcloud compute instances get-serial-port-output $INSTANCE \
printf "Fetching for %s\n" ${SHORT_NAME}
gcloud compute instances get-serial-port-output ${INSTANCE} \
--port 1 \
--start 0 \
--zone $3 > $SHORT_NAME.log
--zone ${ZONE} > ${SHORT_NAME}.log
done