Skip to content

Commit 41f2957

Browse files
authored
Merge pull request #112 from gardenlinux/fix/ci-test-ssh-connection
ci: replace appleboy/ssh-action with plain SSH
2 parents b95b347 + 600e667 commit 41f2957

File tree

4 files changed

+93
-88
lines changed

4 files changed

+93
-88
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ runs:
1313
env:
1414
REPO: ghcr.io/gardenlinux/gardenlinux-ccloud
1515
TAG: ${{ inputs.image_tag }}
16-
ESP_SIZE: 4 # GiB
17-
DISK_SIZE: 8 # GiB
16+
ESP_SIZE: 2 # GiB
17+
DISK_SIZE: 8 # GiB
1818
run: |
1919
echo "REPO=$REPO" >> $GITHUB_ENV
2020
echo "TAG=$TAG" >> $GITHUB_ENV

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

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,52 @@ runs:
3939
sudo virsh define ./.github/actions/test/integration/setup/hv2.xml
4040
sudo virsh start HV2
4141
42-
- name: Wait for HyperVisors to be ready
42+
- name: Configure SSH and libvirt on HyperVisors
4343
shell: bash
4444
run: |
4545
KEY=/opt/ssh_host_ed25519_key
4646
SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
4747
USER="root"
4848
MAX_ITER=30
4949
50+
setup_hv() {
51+
local IP="$1"
52+
53+
# Configure SSH between HyperVisors
54+
scp $SSH_OPTS /opt/ssh_host_ed25519_key "$USER@$IP:/opt/ssh_host_ed25519_key"
55+
ssh $SSH_OPTS "$USER@$IP" << EOF
56+
chmod 700 /root/.ssh
57+
echo "" > /root/.ssh/config
58+
echo "Host 192.168.122.*" >> /root/.ssh/config
59+
echo " StrictHostKeyChecking no" >> /root/.ssh/config
60+
echo " UserKnownHostsFile /dev/null" >> /root/.ssh/config
61+
echo " IdentityFile /opt/ssh_host_ed25519_key" >> /root/.ssh/config
62+
echo " IdentitiesOnly yes" >> /root/.ssh/config
63+
echo " User root" >> /root/.ssh/config
64+
chmod 600 /root/.ssh/config
65+
chmod 600 /opt/ssh_host_ed25519_key
66+
EOF
67+
68+
# Set up libvirt storage pool and network
69+
scp $SSH_OPTS ./.github/actions/test/integration/setup/virbr-vm.xml "$USER@$IP:/opt/virbr-vm.xml"
70+
ssh $SSH_OPTS "$USER@$IP" << EOF
71+
systemctl start libvirtd
72+
73+
virsh pool-destroy default || true
74+
virsh pool-undefine default || true
75+
virsh pool-define-as default dir --target /var/lib/libvirt/images
76+
virsh pool-build default
77+
virsh pool-start default
78+
virsh pool-autostart default
79+
80+
virsh net-destroy default || true
81+
virsh net-undefine default || true
82+
virsh net-define /opt/virbr-vm.xml
83+
virsh net-start default
84+
virsh net-autostart default
85+
EOF
86+
}
87+
5088
wait_for_ssh() {
5189
local VM_NAME="$1"
5290
@@ -56,8 +94,7 @@ runs:
5694
echo "No IP address found for $VM_NAME. Retrying..."
5795
elif ssh $SSH_OPTS "$USER@$IP" 'exit' 2>/dev/null; then
5896
echo "$VM_NAME is up at IP: $IP"
59-
scp $SSH_OPTS ./.github/actions/test/integration/setup/virbr-vm.xml "$USER@$IP:/opt/virbr-vm.xml"
60-
scp $SSH_OPTS /opt/ssh_host_ed25519_key "$USER@$IP:/opt/ssh_host_ed25519_key"
97+
setup_hv "$IP"
6198
break
6299
fi
63100
if (( i == MAX_ITER )); then
@@ -72,43 +109,3 @@ runs:
72109
73110
wait_for_ssh HV1
74111
wait_for_ssh HV2
75-
76-
- name: Configure SSH between HyperVisors
77-
uses: appleboy/ssh-action@v1
78-
with:
79-
host: "192.168.122.2,192.168.122.3"
80-
username: root
81-
key_path: /opt/ssh_host_ed25519_key
82-
script: |
83-
chmod 700 /root/.ssh
84-
echo "" > /root/.ssh/config
85-
echo "Host 192.168.122.*" >> /root/.ssh/config
86-
echo " StrictHostKeyChecking no" >> /root/.ssh/config
87-
echo " UserKnownHostsFile /dev/null" >> /root/.ssh/config
88-
echo " IdentityFile /opt/ssh_host_ed25519_key" >> /root/.ssh/config
89-
echo " IdentitiesOnly yes" >> /root/.ssh/config
90-
echo " User root" >> /root/.ssh/config
91-
chmod 600 /root/.ssh/config
92-
chmod 600 /opt/ssh_host_ed25519_key
93-
94-
- name: Set up network and storage configuration on HyperVisors
95-
uses: appleboy/ssh-action@v1
96-
with:
97-
host: "192.168.122.2,192.168.122.3"
98-
username: root
99-
key_path: /opt/ssh_host_ed25519_key
100-
script: |
101-
systemctl start libvirtd
102-
103-
virsh pool-destroy default || true
104-
virsh pool-undefine default || true
105-
virsh pool-define-as default dir --target /var/lib/libvirt/images
106-
virsh pool-build default
107-
virsh pool-start default
108-
virsh pool-autostart default
109-
110-
virsh net-destroy default || true
111-
virsh net-undefine default || true
112-
virsh net-define /opt/virbr-vm.xml
113-
virsh net-start default
114-
virsh net-autostart default

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

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,90 +20,100 @@ runs:
2020
scp $SSH_OPTS /opt/ubuntu-cloud-init-ds.iso "$USER@$IP_HV2:/var/lib/libvirt/images/ubuntu-cloud-init-ds.iso"
2121
2222
- name: Start VM on HyperVisor 1
23-
uses: appleboy/ssh-action@v1
24-
with:
25-
host: 192.168.122.2
26-
username: root
27-
key_path: /opt/ssh_host_ed25519_key
28-
script: |
23+
shell: bash
24+
run: |
25+
KEY=/opt/ssh_host_ed25519_key
26+
SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
27+
USER="root"
28+
IP_HV1="192.168.122.2"
29+
30+
ssh $SSH_OPTS "$USER@$IP_HV1" << EOF
2931
virsh define /opt/vm.xml
3032
virsh start VM
33+
EOF
3134
3235
- name: Wait for VM to be ready
33-
uses: appleboy/ssh-action@v1
34-
with:
35-
host: 192.168.122.2
36-
username: root
37-
key_path: /opt/ssh_host_ed25519_key
38-
script: |
36+
shell: bash
37+
run: |
38+
KEY=/opt/ssh_host_ed25519_key
39+
SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
40+
USER="root"
41+
IP_HV1="192.168.122.2"
42+
43+
ssh $SSH_OPTS "$USER@$IP_HV1" << EOF
3944
KEY=/opt/ssh_host_ed25519_key
40-
SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
45+
SSH_OPTS="-i \$KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
4146
USER="root"
4247
4348
MAX_ITER=40
4449
for ((i=1; i<=MAX_ITER; i++)); do
45-
IP=$(virsh domifaddr VM | awk '/ipv4/ {print $4}' | cut -d'/' -f1)
46-
if [ -z "$IP" ]; then
50+
IP=\$(virsh domifaddr VM | awk '/ipv4/ {print \$4}' | cut -d'/' -f1)
51+
if [ -z "\$IP" ]; then
4752
echo "No IP address found for VM. Retrying..."
48-
elif ssh $SSH_OPTS "$USER@$IP" 'exit' 2>/dev/null; then
49-
echo "VM is up at IP: $IP"
53+
elif ssh \$SSH_OPTS "\$USER@\$IP" 'exit' 2>/dev/null; then
54+
echo "VM is up at IP: \$IP"
5055
# create a dummy file for verification later
51-
ssh $SSH_OPTS "$USER@$IP" 'echo "Hello, World!" > /opt/hello.txt'
56+
ssh \$SSH_OPTS "\$USER@\$IP" 'echo "Hello, World!" > /opt/hello.txt'
5257
break
5358
fi
5459
if (( i == MAX_ITER )); then
5560
echo "Timeout waiting for VM to respond to SSH."
5661
cat /var/log/VM.log
5762
exit 1
5863
fi
59-
echo "Waiting for VM to respond to SSH... ($i/$MAX_ITER)"
64+
echo "Waiting for VM to respond to SSH... (\$i/\$MAX_ITER)"
6065
sleep 10
6166
done
67+
EOF
6268
6369
- name: Mirgrate the VM to HyperVisor 2
64-
uses: appleboy/ssh-action@v1
65-
with:
66-
host: 192.168.122.2
67-
username: root
68-
key_path: /opt/ssh_host_ed25519_key
69-
script: |
70+
shell: bash
71+
run: |
72+
KEY=/opt/ssh_host_ed25519_key
73+
SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
74+
USER="root"
75+
IP_HV1="192.168.122.2"
76+
77+
ssh $SSH_OPTS "$USER@$IP_HV1" << EOF
7078
USER="root"
71-
HV2_IP="192.168.122.3"
79+
IP_HV2="192.168.122.3"
7280
73-
virsh migrate --persistent --undefinesource --copy-storage-all --live VM qemu+ssh://$USER@$HV2_IP/system
81+
virsh migrate --persistent --undefinesource --copy-storage-all --live VM qemu+ssh://\$USER@\$IP_HV2/system
7482
if virsh dominfo VM &>/dev/null; then
7583
echo "VM is still present on HV1 after migration!"
7684
exit 1
7785
fi
86+
EOF
7887
7988
- name: Verify VM status on HyperVisor 2
80-
uses: appleboy/ssh-action@v1
81-
with:
82-
host: 192.168.122.3
83-
username: root
84-
key_path: /opt/ssh_host_ed25519_key
85-
command_timeout: 30m
86-
script: |
87-
if virsh dominfo VM | awk '/State:/ {print $2}' | grep -q "running"; then
89+
shell: bash
90+
run: |
91+
KEY=/opt/ssh_host_ed25519_key
92+
SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
93+
USER="root"
94+
IP_HV2="192.168.122.3"
95+
96+
ssh $SSH_OPTS "$USER@$IP_HV2" << EOF
97+
if virsh dominfo VM | awk '/State:/ {print \$2}' | grep -q "running"; then
8898
echo "VM is running on HV2."
8999
else
90100
echo "VM is not running on HV2."
91101
exit 1
92102
fi
93103
94104
KEY=/opt/ssh_host_ed25519_key
95-
SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
105+
SSH_OPTS="-i \$KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
96106
USER="root"
97107
# waiting for the IP to be visible to the new HyperVisor via DHCP takes WAYYYYYYY too long
98108
# the IP is static, so we can just use it directly
99109
IP="192.168.222.2"
100110
101111
MAX_ITER=40
102112
for ((i=1; i<=MAX_ITER; i++)); do
103-
if ssh $SSH_OPTS "$USER@$IP" 'exit' 2>/dev/null; then
104-
echo "VM is up at IP: $IP"
113+
if ssh \$SSH_OPTS "\$USER@\$IP" 'exit' 2>/dev/null; then
114+
echo "VM is up at IP: \$IP"
105115
# verify the migration by checking the dummy file
106-
if ssh $SSH_OPTS "$USER@$IP" 'test -f /opt/hello.txt'; then
116+
if ssh \$SSH_OPTS "\$USER@\$IP" 'test -f /opt/hello.txt'; then
107117
echo "Dummy file exists on VM, migration successful."
108118
break
109119
else
@@ -116,6 +126,7 @@ runs:
116126
cat /var/log/VM.log
117127
exit 1
118128
fi
119-
echo "Waiting for VM to respond to SSH... ($i/$MAX_ITER)"
129+
echo "Waiting for VM to respond to SSH... (\$i/\$MAX_ITER)"
120130
sleep 10
121131
done
132+
EOF

.github/workflows/test.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: test hypervisor capabilities
22
on:
3-
push:
4-
branches:
5-
- ci-test-virtualization
63
workflow_run:
74
workflows:
85
- nightly

0 commit comments

Comments
 (0)