AB#2392 Store serial logs in actions (#39)

Co-authored-by: Fabian Kammel <fk@edgeless.systems>
This commit is contained in:
Fabian Kammel 2022-09-05 18:12:46 +02:00 committed by GitHub
parent 50acded80b
commit 020cf51fc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 0 deletions

View File

@ -159,3 +159,31 @@ runs:
if [ ${{ inputs.autoscale }} = true ]; then autoscale=--autoscale; fi
constellation init ${autoscale}
shell: bash
- name: Download boot logs
run: |
echo "::group::Download boot logs"
case $CSP in
azure)
AZURE_RESOURCE_GROUP=$(yq eval ".provider.azure.resourceGroup" constellation-conf.yaml)
./.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}
;;
esac
echo "::endgroup::"
shell: bash
env:
CSP: ${{ inputs.cloudProvider }}
continue-on-error: true
if: ${{ always() }}
- name: Upload boot logs
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8
with:
name: serial-logs
path: '*.log'
if: ${{ always() && !env.ACT }}

View File

@ -0,0 +1,21 @@
#!/bin/bash
printf "Fetching logs of instances in resource group %s\n" $1
# get list of all scale sets
scalesetsjson=$(az vmss list --resource-group $1 -o json)
scalesetslist=$(echo $scalesetsjson | jq -r '.[] | .name')
subscription=$(az account show | jq -r .id)
printf "Checking scalesets %s\n" $scalesetslist
for scaleset in $scalesetslist; do
instanceids=$(az vmss list-instances --resource-group $1 --name ${scaleset} -o json | jq -r '.[] | .instanceId')
printf "Checking instance IDs %s\n" $instanceids
for instanceid in $instanceids; do
bloburi=$(az rest --method post --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)
sleep 4
curl -sL -o "./${scaleset}-${instanceid}.log" $bloburi
echo $(realpath "./${scaleset}-${instanceid}.log")
done
done

View File

@ -0,0 +1,18 @@
#!/bin/bash
# Usage: ./gcp-logs.sh <control-instance-group-name> <worker-instance-group-name> <zone>
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
for INSTANCE in $ALL_INSTANCES; do
SHORT_NAME=${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
done

View File

@ -67,6 +67,11 @@ func runInitialize(cmd *cobra.Command, args []string) error {
return dialer.New(nil, validator.V(cmd), &net.Dialer{})
}
helmLoader := &helm.ChartLoader{}
ctx, cancel := context.WithTimeout(cmd.Context(), time.Hour)
defer cancel()
cmd.SetContext(ctx)
return initialize(cmd, newDialer, fileHandler, helmLoader, license.NewClient())
}