2022-10-10 08:21:17 -04:00
|
|
|
#!/usr/bin/env bash
|
2022-09-05 12:12:46 -04:00
|
|
|
|
2022-11-10 04:28:35 -05:00
|
|
|
set -euo pipefail
|
|
|
|
shopt -s inherit_errexit
|
2022-10-31 05:40:08 -04:00
|
|
|
|
2022-12-08 10:55:56 -05:00
|
|
|
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
|
2022-10-31 05:40:08 -04:00
|
|
|
|
2022-12-08 10:55:56 -05:00
|
|
|
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'
|
|
|
|
)
|
2022-09-05 12:12:46 -04:00
|
|
|
|
2022-12-08 10:55:56 -05:00
|
|
|
allInstances="${controlInstances} ${workerInstances}"
|
2022-09-05 12:12:46 -04:00
|
|
|
|
2022-11-10 04:28:35 -05:00
|
|
|
printf "Fetching logs for %s and %s\n" "${controlInstances}" "${workerInstances}"
|
|
|
|
|
2022-12-08 10:55:56 -05:00
|
|
|
for instance in ${allInstances}; do
|
|
|
|
shortName=${instance##*/}
|
|
|
|
printf "Fetching for %s\n" "${shortName}"
|
|
|
|
gcloud compute instances get-serial-port-output "${instance}" \
|
2022-09-05 12:12:46 -04:00
|
|
|
--port 1 \
|
|
|
|
--start 0 \
|
2022-12-08 10:55:56 -05:00
|
|
|
--zone "${zone}" > "${shortName}".log
|
2022-09-05 12:12:46 -04:00
|
|
|
done
|