Skip to content

Commit 119a3ea

Browse files
authored
CI: Fetch DevStack and k3s logs (kubernetes#2527)
This commit makes sure we're fetching and putting the logs of the DevStack services as well as k3s into the artifacts for every CI job.
1 parent 7373f0c commit 119a3ea

7 files changed

Lines changed: 83 additions & 4 deletions

File tree

tests/ci-csi-cinder-e2e.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ ansible-playbook -v \
110110
tests/playbooks/test-csi-cinder-e2e.yaml
111111
exit_code=$?
112112

113+
# Fetch logs for debugging purpose
114+
ansible-playbook -v \
115+
--user ${USERNAME} \
116+
--private-key ~/.ssh/google_compute_engine \
117+
--inventory ${PUBLIC_IP}, \
118+
--ssh-common-args "-o StrictHostKeyChecking=no" \
119+
tests/playbooks/fetch-logs.yaml
120+
121+
scp -i ~/.ssh/google_compute_engine \
122+
-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
123+
-r ${USERNAME}@${PUBLIC_IP}:~/logs $ARTIFACTS/logs/devstack || true
124+
113125
# Fetch cinder-csi tests logs for debugging purpose
114126
scp -i ~/.ssh/google_compute_engine \
115127
-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \

tests/ci-csi-manila-e2e.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ ansible-playbook -v \
110110
tests/playbooks/test-csi-manila-e2e.yaml
111111
exit_code=$?
112112

113+
# Fetch logs for debugging purpose
114+
ansible-playbook -v \
115+
--user ${USERNAME} \
116+
--private-key ~/.ssh/google_compute_engine \
117+
--inventory ${PUBLIC_IP}, \
118+
--ssh-common-args "-o StrictHostKeyChecking=no" \
119+
tests/playbooks/fetch-logs.yaml
120+
121+
scp -i ~/.ssh/google_compute_engine \
122+
-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
123+
-r ${USERNAME}@${PUBLIC_IP}:~/logs $ARTIFACTS/logs/devstack || true
124+
113125
# Fetch manila-csi tests results
114126
scp -i ~/.ssh/google_compute_engine \
115127
-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \

tests/ci-occm-e2e.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,17 @@ ansible-playbook -v \
113113
-e run_e2e=true
114114
exit_code=$?
115115

116-
# Fetch devstack logs for debugging purpose
117-
# scp -i ~/.ssh/google_compute_engine \
118-
# -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
119-
# -r ${USERNAME}@${PUBLIC_IP}:/opt/stack/logs $ARTIFACTS/logs/devstack || true
116+
# Fetch logs for debugging purpose
117+
ansible-playbook -v \
118+
--user ${USERNAME} \
119+
--private-key ~/.ssh/google_compute_engine \
120+
--inventory ${PUBLIC_IP}, \
121+
--ssh-common-args "-o StrictHostKeyChecking=no" \
122+
tests/playbooks/fetch-logs.yaml
123+
124+
scp -i ~/.ssh/google_compute_engine \
125+
-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
126+
-r ${USERNAME}@${PUBLIC_IP}:~/logs $ARTIFACTS/logs/devstack || true
120127

121128
# Fetch octavia amphora image build logs for debugging purpose
122129
scp -i ~/.ssh/google_compute_engine \

tests/playbooks/fetch-logs.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- hosts: all
2+
become: true
3+
become_method: sudo
4+
gather_facts: true
5+
6+
vars:
7+
user: stack
8+
devstack_workdir: /home/{{ user }}/devstack
9+
10+
roles:
11+
- role: fetch-logs
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The ansible role gets logs of various services running in the CI for further analysis
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
master_port_name: "k3s_master"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
- name: Get k3s master floating IP
2+
shell:
3+
executable: /bin/bash
4+
cmd: |
5+
set +x; source {{ devstack_workdir }}/openrc demo demo > /dev/null
6+
openstack floating ip list --port {{ master_port_name }} -c "Floating IP Address" -f value
7+
register: fip
8+
9+
- name: Set fact for k3s master floating IP
10+
set_fact:
11+
k3s_fip: "{{ fip.stdout }}"
12+
13+
- name: Creates directory
14+
ansible.builtin.file:
15+
path: "/root/logs"
16+
state: directory
17+
18+
- name: Fetch k3s logs
19+
shell:
20+
executable: /bin/bash
21+
cmd: |
22+
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{ ansible_user_dir }}/.ssh/id_rsa ubuntu@{{ k3s_fip }} sudo journalctl -u k3s.service --no-pager > /root/logs/k3s.log
23+
24+
- name: Fetch DevStack logs
25+
shell:
26+
executable: /bin/bash
27+
cmd: |
28+
set +x;
29+
units=`systemctl list-units --type service | awk '{ print $1 }' | grep devstack\@`
30+
for unit in $units; do
31+
filename=${unit#"devstack@"}
32+
filename=${filename%".service"}
33+
sudo journalctl -u $unit --no-pager > /root/logs/${filename}.log
34+
done;

0 commit comments

Comments
 (0)