ci: fix download scripts for serial logs

Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
Paul Meyer 2022-12-08 16:55:56 +01:00
parent 9e9468ff44
commit d3873988c9
2 changed files with 45 additions and 14 deletions

View File

@ -2,6 +2,12 @@
# Usage: ./aws-logs.sh <region>
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 \

View File

@ -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