Skip to content

Commit 9d02797

Browse files
authored
Merge pull request #115 from gardenlinux/feat/ci-emergency-logging
feat: Store Logs from CI Runs for Debugging and Offline Analysis
2 parents c516575 + 91152e9 commit 9d02797

File tree

4 files changed

+49
-30
lines changed

4 files changed

+49
-30
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: collect-logs
2+
description: Store debugging information for offline analysis
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Obtain logs from test runner
7+
shell: bash
8+
run: |
9+
sudo cp /var/log/libvirt/qemu/HV1.log "libvirt-HV1.log" || true
10+
sudo cp /var/log/libvirt/qemu/HV2.log "libvirt-HV2.log" || true
11+
sudo journalctl --no-pager > journal-RUNNER.log || true
12+
13+
- name: Obtain logs from hypervisors
14+
shell: bash
15+
run: |
16+
KEY=/opt/ssh_host_ed25519_key
17+
SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
18+
USER="root"
19+
HV1_IP="192.168.122.2"
20+
HV2_IP="192.168.122.3"
21+
22+
ssh $SSH_OPTS $USER@$HV1_IP "journalctl --no-pager" > "journal-HV1.log" || true
23+
scp $SSH_OPTS $USER@$HV1_IP:/var/log/libvirt/qemu/VM-QEMU.log "libvirt-VM-QEMU-HV1.log" || true
24+
scp $SSH_OPTS $USER@$HV1_IP:/var/log/libvirt/ch/VM-CHV.log "libvirt-VM-CHV-HV1.log" || true
25+
scp $SSH_OPTS $USER@$HV1_IP:/var/log/QEMU.log "serial-VM-QEMU-HV1.log" || true
26+
27+
ssh $SSH_OPTS $USER@$HV2_IP "journalctl --no-pager" > "journal-HV2.log" || true
28+
scp $SSH_OPTS $USER@$HV2_IP:/var/log/libvirt/qemu/VM-QEMU.log "libvirt-VM-QEMU-HV2.log" || true
29+
scp $SSH_OPTS $USER@$HV2_IP:/var/log/libvirt/ch/VM-CHV.log "libvirt-VM-CHV-HV2.log" || true
30+
scp $SSH_OPTS $USER@$HV2_IP:/var/log/QEMU.log "serial-VM-QEMU-HV2.log" || true
31+
32+
- name: Set permissions
33+
shell: bash
34+
run: |
35+
sudo chmod 644 *.log
36+
37+
- name: Upload artifacts
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: debug-logs
41+
path: "*.log"
42+

.github/actions/test/integration/test/cloudhypervisor/action.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ runs:
4747
SSH_OPTS="-i \$KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
4848
USER="root"
4949
50-
MAX_ITER=40
50+
MAX_ITER=60
5151
for ((i=1; i<=MAX_ITER; i++)); do
5252
IP=\$(virsh -c ch:///session domifaddr VM-CHV | awk '/ipv4/ {print \$4}' | cut -d'/' -f1)
5353
if [ -z "\$IP" ]; then
@@ -60,7 +60,6 @@ runs:
6060
fi
6161
if (( i == MAX_ITER )); then
6262
echo "Timeout waiting for VM to respond to SSH."
63-
cat /var/log/CHV.log
6463
exit 1
6564
fi
6665
echo "Waiting for VM to respond to SSH... (\$i/\$MAX_ITER)"
@@ -110,7 +109,7 @@ runs:
110109
# the IP is static, so we can just use it directly
111110
IP="192.168.222.3"
112111
113-
MAX_ITER=40
112+
MAX_ITER=15
114113
for ((i=1; i<=MAX_ITER; i++)); do
115114
if ssh \$SSH_OPTS "\$USER@\$IP" 'exit' ; then
116115
echo "VM is up at IP: \$IP"
@@ -125,7 +124,6 @@ runs:
125124
fi
126125
if (( i == MAX_ITER )); then
127126
echo "Timeout waiting for VM to respond to SSH."
128-
cat /var/log/CHV.log
129127
exit 1
130128
fi
131129
echo "Waiting for VM to respond to SSH... (\$i/\$MAX_ITER)"

.github/actions/test/integration/test/qemu/action.yml

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ runs:
4545
SSH_OPTS="-i \$KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
4646
USER="root"
4747
48-
MAX_ITER=40
48+
MAX_ITER=60
4949
for ((i=1; i<=MAX_ITER; i++)); do
5050
IP=\$(virsh domifaddr VM-QEMU | awk '/ipv4/ {print \$4}' | cut -d'/' -f1)
5151
if [ -z "\$IP" ]; then
@@ -58,7 +58,6 @@ runs:
5858
fi
5959
if (( i == MAX_ITER )); then
6060
echo "Timeout waiting for VM to respond to SSH."
61-
cat /var/log/QEMU.log
6261
exit 1
6362
fi
6463
echo "Waiting for VM to respond to SSH... (\$i/\$MAX_ITER)"
@@ -108,7 +107,7 @@ runs:
108107
# the IP is static, so we can just use it directly
109108
IP="192.168.222.2"
110109
111-
MAX_ITER=40
110+
MAX_ITER=15
112111
for ((i=1; i<=MAX_ITER; i++)); do
113112
if ssh \$SSH_OPTS "\$USER@\$IP" 'exit' 2>/dev/null; then
114113
echo "VM is up at IP: \$IP"
@@ -123,32 +122,9 @@ runs:
123122
fi
124123
if (( i == MAX_ITER )); then
125124
echo "Timeout waiting for VM to respond to SSH."
126-
cat /var/log/QEMU.log
127125
exit 1
128126
fi
129127
echo "Waiting for VM to respond to SSH... (\$i/\$MAX_ITER)"
130128
sleep 10
131129
done
132130
EOF
133-
134-
- name: Clean up HyperVisors
135-
shell: bash
136-
run: |
137-
KEY=/opt/ssh_host_ed25519_key
138-
SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
139-
USER="root"
140-
IP_HV1="192.168.122.2"
141-
IP_HV2="192.168.122.3"
142-
143-
cleanup() {
144-
local IP="$1"
145-
ssh $SSH_OPTS "$USER@$IP" << EOF
146-
virsh destroy VM-QEMU || true
147-
virsh undefine VM-QEMU --nvram --tpm --remove-all-storage
148-
rm -f /var/lib/libvirt/images/ubuntu.qcow2
149-
rm -f /opt/vm-qemu.xml
150-
EOF
151-
}
152-
153-
cleanup "$IP_HV1"
154-
cleanup "$IP_HV2"

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ jobs:
4040
uses: ./.github/actions/test/integration/test/qemu
4141
- name: Test CloudHypervisor
4242
uses: ./.github/actions/test/integration/test/cloudhypervisor
43+
- name: Collect Debug Logs
44+
if: always()
45+
uses: ./.github/actions/test/integration/collect-logs

0 commit comments

Comments
 (0)