From d3873988c94831355a142a624e9bc53baf9e951d Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Thu, 8 Dec 2022 16:55:56 +0100 Subject: [PATCH] ci: fix download scripts for serial logs Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- .../actions/constellation_create/aws-logs.sh | 7 +++ .../actions/constellation_create/gcp-logs.sh | 52 ++++++++++++++----- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/.github/actions/constellation_create/aws-logs.sh b/.github/actions/constellation_create/aws-logs.sh index 40cccf614..2651840d2 100755 --- a/.github/actions/constellation_create/aws-logs.sh +++ b/.github/actions/constellation_create/aws-logs.sh @@ -2,6 +2,12 @@ # Usage: ./aws-logs.sh +set -euo pipefail +shopt -s inherit_errexit + +echo "Using AWS region: ${1}" + +pushd constellation-terraform controlAutoscalingGroup=$( terraform show -json | jq -r .'values.root_module.child_modules[] | @@ -14,6 +20,7 @@ workerAutoscalingGroup=$( select(.address == "module.instance_group_worker_nodes") | .resources[0].values.name' ) +popd controlInstances=$( aws autoscaling describe-auto-scaling-groups \ diff --git a/.github/actions/constellation_create/gcp-logs.sh b/.github/actions/constellation_create/gcp-logs.sh index 735a19420..168f47522 100755 --- a/.github/actions/constellation_create/gcp-logs.sh +++ b/.github/actions/constellation_create/gcp-logs.sh @@ -3,25 +3,49 @@ set -euo pipefail shopt -s inherit_errexit -controlInstanceGroup=$(terraform show -json | jq -r .'values.root_module.child_modules[] | select(.address == "module.instance_group_control_plane") | .resources[0].values.base_instance_name') -workerInstanceGroup=$(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') +pushd constellation-terraform +controlInstanceGroup=$( + terraform show -json | + jq -r .'values.root_module.child_modules[] | + select(.address == "module.instance_group_control_plane") | + .resources[0].values.base_instance_name' +) +workerInstanceGroup=$( + 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' +) +popd -controlInstanceGroup=${controlInstanceGroup##*/} -workerInstanceGroupShort=${workerInstanceGroup##*/} +controlInstances=$( + gcloud compute instance-groups managed list-instances "${controlInstanceGroup##*/}" \ + --zone "${zone}" \ + --format=json | + jq -r '.[] | .instance' +) +workerInstances=$( + gcloud compute instance-groups managed list-instances "${workerInstanceGroup##*/}" \ + --zone "${zone}" \ + --format=json | + jq -r '.[] | .instance' +) -controlInstances=$(gcloud compute instance-groups managed list-instances "${controlInstanceGroup}" --zone "${zone}" --format=json | jq -r '.[] | .instance') -workerInstances=$(gcloud compute instance-groups managed list-instances "${workerInstanceGroupShort}" --zone "${zone}" --format=json | jq -r '.[] | .instance') - -ALL_INSTANCES="${controlInstances} ${workerInstances}" +allInstances="${controlInstances} ${workerInstances}" printf "Fetching logs for %s and %s\n" "${controlInstances}" "${workerInstances}" -for INSTANCE in ${ALL_INSTANCES}; do - SHORT_NAME=${INSTANCE##*/} - printf "Fetching for %s\n" "${SHORT_NAME}" - gcloud compute instances get-serial-port-output "${INSTANCE}" \ +for instance in ${allInstances}; do + shortName=${instance##*/} + printf "Fetching for %s\n" "${shortName}" + gcloud compute instances get-serial-port-output "${instance}" \ --port 1 \ --start 0 \ - --zone "${zone}" > "${SHORT_NAME}".log + --zone "${zone}" > "${shortName}".log done