mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-01-26 07:16:08 -05:00
ci: fix resource selection for serial log downloading (#2101)
Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com> Co-authored-by: Otto Bittner <cobittner@posteo.net>
This commit is contained in:
parent
6ed8fce6b0
commit
43076e96a6
10
.github/actions/constellation_create/action.yml
vendored
10
.github/actions/constellation_create/action.yml
vendored
@ -282,16 +282,18 @@ runs:
|
|||||||
CSP: ${{ inputs.cloudProvider }}
|
CSP: ${{ inputs.cloudProvider }}
|
||||||
run: |
|
run: |
|
||||||
echo "::group::Download boot logs"
|
echo "::group::Download boot logs"
|
||||||
|
CONSTELL_UID=$(yq '.uid' constellation-id.json)
|
||||||
case $CSP in
|
case $CSP in
|
||||||
azure)
|
azure)
|
||||||
AZURE_RESOURCE_GROUP=$(yq eval ".provider.azure.resourceGroup" constellation-conf.yaml)
|
AZURE_RESOURCE_GROUP=$(yq eval ".provider.azure.resourceGroup" constellation-conf.yaml)
|
||||||
./.github/actions/constellation_create/az-logs.sh ${AZURE_RESOURCE_GROUP}
|
./.github/actions/constellation_create/az-logs.sh ${AZURE_RESOURCE_GROUP}
|
||||||
;;
|
;;
|
||||||
gcp)
|
gcp)
|
||||||
./.github/actions/constellation_create/gcp-logs.sh
|
GCP_ZONE=$(yq eval ".provider.gcp.zone" constellation-conf.yaml)
|
||||||
|
./.github/actions/constellation_create/gcp-logs.sh ${GCP_ZONE} ${CONSTELL_UID}
|
||||||
;;
|
;;
|
||||||
aws)
|
aws)
|
||||||
./.github/actions/constellation_create/aws-logs.sh us-east-2
|
./.github/actions/constellation_create/aws-logs.sh us-east-2 ${CONSTELL_UID}
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
@ -302,4 +304,6 @@ runs:
|
|||||||
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
|
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
|
||||||
with:
|
with:
|
||||||
name: serial-logs-${{ inputs.artifactNameSuffix }}
|
name: serial-logs-${{ inputs.artifactNameSuffix }}
|
||||||
path: "*.log"
|
path: |
|
||||||
|
*.log
|
||||||
|
!terraform.log
|
||||||
|
47
.github/actions/constellation_create/aws-logs.sh
vendored
47
.github/actions/constellation_create/aws-logs.sh
vendored
@ -6,51 +6,26 @@ set -euo pipefail
|
|||||||
shopt -s inherit_errexit
|
shopt -s inherit_errexit
|
||||||
|
|
||||||
echo "Using AWS region: ${1}"
|
echo "Using AWS region: ${1}"
|
||||||
|
echo "Using Constellation UID: ${2}"
|
||||||
# TODO(msanft): Remove once 2.9.0 is released
|
|
||||||
CP_SELECTOR="module.instance_group_control_plane"
|
|
||||||
W_SELECTOR="module.instance_group_worker_nodes"
|
|
||||||
if [[ $(./constellation version) != *"2.8.0"* ]]; then
|
|
||||||
echo "Constellation version is not 2.8.0, using updated ASG selectors"
|
|
||||||
CP_SELECTOR='module.instance_group["control_plane_default"]'
|
|
||||||
W_SELECTOR='module.instance_group["worker_default"]'
|
|
||||||
fi
|
|
||||||
|
|
||||||
pushd constellation-terraform
|
|
||||||
controlAutoscalingGroup=$(
|
|
||||||
terraform show -json |
|
|
||||||
jq --arg selector "$CP_SELECTOR" \
|
|
||||||
-r .'values.root_module.child_modules[] |
|
|
||||||
select(.address == $selector) |
|
|
||||||
.resources[0].values.name'
|
|
||||||
)
|
|
||||||
workerAutoscalingGroup=$(
|
|
||||||
terraform show -json |
|
|
||||||
jq --arg selector "$W_SELECTOR" \
|
|
||||||
-r .'values.root_module.child_modules[] |
|
|
||||||
select(.address == $selector) |
|
|
||||||
.resources[0].values.name'
|
|
||||||
)
|
|
||||||
popd
|
|
||||||
|
|
||||||
controlInstances=$(
|
controlInstances=$(
|
||||||
aws autoscaling describe-auto-scaling-groups \
|
aws ec2 describe-instances \
|
||||||
|
--filters "Name=tag:constellation-uid,Values=${2}" "Name=tag:constellation-role,Values=control-plane" \
|
||||||
--region "${1}" \
|
--region "${1}" \
|
||||||
--no-paginate \
|
--no-paginate \
|
||||||
--output json \
|
--output json |
|
||||||
--auto-scaling-group-names "${controlAutoscalingGroup}" |
|
yq eval '.Reservations[].Instances[].InstanceId' -
|
||||||
jq -r '.AutoScalingGroups[0].Instances[].InstanceId'
|
|
||||||
)
|
)
|
||||||
workerInstances=$(
|
workerInstances=$(
|
||||||
aws autoscaling describe-auto-scaling-groups \
|
aws ec2 describe-instances \
|
||||||
|
--filters "Name=tag:constellation-uid,Values=${2}" "Name=tag:constellation-role,Values=worker" \
|
||||||
--region "${1}" \
|
--region "${1}" \
|
||||||
--no-paginate \
|
--no-paginate \
|
||||||
--output json \
|
--output json |
|
||||||
--auto-scaling-group-names "${workerAutoscalingGroup}" |
|
yq eval '.Reservations[].Instances[].InstanceId' -
|
||||||
jq -r '.AutoScalingGroups[0].Instances[].InstanceId'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
echo "Fetching logs from control planes: ${controlInstances}"
|
echo "Fetching logs from control planes"
|
||||||
|
|
||||||
for instance in ${controlInstances}; do
|
for instance in ${controlInstances}; do
|
||||||
printf "Fetching for %s\n" "${instance}"
|
printf "Fetching for %s\n" "${instance}"
|
||||||
@ -59,7 +34,7 @@ for instance in ${controlInstances}; do
|
|||||||
tail -n +2 > control-plane-"${instance}".log
|
tail -n +2 > control-plane-"${instance}".log
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Fetching logs from worker nodes: ${workerInstances}"
|
echo "Fetching logs from worker nodes"
|
||||||
|
|
||||||
for instance in ${workerInstances}; do
|
for instance in ${workerInstances}; do
|
||||||
printf "Fetching for %s\n" "${instance}"
|
printf "Fetching for %s\n" "${instance}"
|
||||||
|
@ -7,8 +7,8 @@ printf "Fetching logs of instances in resource group %s\n" "${1}"
|
|||||||
|
|
||||||
# get list of all scale sets
|
# get list of all scale sets
|
||||||
scalesetsjson=$(az vmss list --resource-group "${1}" -o json)
|
scalesetsjson=$(az vmss list --resource-group "${1}" -o json)
|
||||||
scalesetslist=$(echo "${scalesetsjson}" | jq -r '.[] | .name')
|
scalesetslist=$(echo "${scalesetsjson}" | yq eval '.[] | .name' -)
|
||||||
subscription=$(az account show | jq -r .id)
|
subscription=$(az account show | yq eval .id -)
|
||||||
|
|
||||||
printf "Checking scalesets %s\n" "${scalesetslist}"
|
printf "Checking scalesets %s\n" "${scalesetslist}"
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ for scaleset in ${scalesetslist}; do
|
|||||||
--resource-group "${1}" \
|
--resource-group "${1}" \
|
||||||
--name "${scaleset}" \
|
--name "${scaleset}" \
|
||||||
-o json |
|
-o json |
|
||||||
jq -r '.[] | .instanceId'
|
yq eval '.[] | .instanceId' -
|
||||||
)
|
)
|
||||||
printf "Checking instance IDs %s\n" "${instanceids}"
|
printf "Checking instance IDs %s\n" "${instanceids}"
|
||||||
for instanceid in ${instanceids}; do
|
for instanceid in ${instanceids}; do
|
||||||
@ -26,7 +26,7 @@ for scaleset in ${scalesetslist}; do
|
|||||||
az rest \
|
az rest \
|
||||||
--method post \
|
--method post \
|
||||||
--url https://management.azure.com/subscriptions/"${subscription}"/resourceGroups/"${1}"/providers/Microsoft.Compute/virtualMachineScaleSets/"${scaleset}"/virtualmachines/"${instanceid}"/retrieveBootDiagnosticsData?api-version=2022-03-01 |
|
--url https://management.azure.com/subscriptions/"${subscription}"/resourceGroups/"${1}"/providers/Microsoft.Compute/virtualMachineScaleSets/"${scaleset}"/virtualmachines/"${instanceid}"/retrieveBootDiagnosticsData?api-version=2022-03-01 |
|
||||||
jq '.serialConsoleLogBlobUri' -r
|
yq eval '.serialConsoleLogBlobUri' -
|
||||||
)
|
)
|
||||||
sleep 4
|
sleep 4
|
||||||
curl -fsSL -o "./${scaleset}-${instanceid}.log" "${bloburi}"
|
curl -fsSL -o "./${scaleset}-${instanceid}.log" "${bloburi}"
|
||||||
|
46
.github/actions/constellation_create/gcp-logs.sh
vendored
46
.github/actions/constellation_create/gcp-logs.sh
vendored
@ -3,49 +3,19 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
shopt -s inherit_errexit
|
shopt -s inherit_errexit
|
||||||
|
|
||||||
pushd constellation-terraform
|
echo "Using Zone: ${1}"
|
||||||
controlInstanceGroup=$(
|
echo "Using Constellation UID: ${2}"
|
||||||
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
|
|
||||||
|
|
||||||
controlInstances=$(
|
allInstances=$(
|
||||||
gcloud compute instance-groups managed list-instances "${controlInstanceGroup##*/}" \
|
gcloud compute instances list \
|
||||||
--zone "${zone}" \
|
--filter="labels.constellation-uid=${2}" \
|
||||||
--format=json |
|
--format=json | yq eval '.[] | .name' -
|
||||||
jq -r '.[] | .instance'
|
|
||||||
)
|
)
|
||||||
workerInstances=$(
|
|
||||||
gcloud compute instance-groups managed list-instances "${workerInstanceGroup##*/}" \
|
|
||||||
--zone "${zone}" \
|
|
||||||
--format=json |
|
|
||||||
jq -r '.[] | .instance'
|
|
||||||
)
|
|
||||||
|
|
||||||
allInstances="${controlInstances} ${workerInstances}"
|
|
||||||
|
|
||||||
printf "Fetching logs for %s and %s\n" "${controlInstances}" "${workerInstances}"
|
|
||||||
|
|
||||||
for instance in ${allInstances}; do
|
for instance in ${allInstances}; do
|
||||||
shortName=${instance##*/}
|
printf "Fetching for %s\n" "${instance}"
|
||||||
printf "Fetching for %s\n" "${shortName}"
|
|
||||||
gcloud compute instances get-serial-port-output "${instance}" \
|
gcloud compute instances get-serial-port-output "${instance}" \
|
||||||
--port 1 \
|
--port 1 \
|
||||||
--start 0 \
|
--start 0 \
|
||||||
--zone "${zone}" > "${shortName}".log
|
--zone "${1}" > "${instance}".log
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user