66 - name : Copy VM defintions and artifacts to the HyperVisors
77 shell : bash
88 run : |
9- KEY=/opt/ssh_host_ed25519_key
10- SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
11- USER="root"
9+ # Required from the job environment; the shared key is the identity
10+ # that the ssh config names.
11+ [ -s /opt/ssh_host_ed25519_key ] || { echo "the shared SSH key /opt/ssh_host_ed25519_key is missing" >&2; exit 1; }
1212 IP_HV1="192.168.122.2"
1313 IP_HV2="192.168.122.3"
1414
15- scp $SSH_OPTS ./.github/actions/test/integration/test/cloudhypervisor/vm.xml "$USER@ $IP_HV1:/opt/vm-chv.xml"
16- scp $SSH_OPTS /opt/ubuntu.raw "$USER@ $IP_HV1:/var/lib/libvirt/images/ubuntu.raw"
17- scp $SSH_OPTS /opt/ubuntu-cloud-init-ds.iso "$USER@ $IP_HV1:/var/lib/libvirt/images/ubuntu-cloud-init-ds.iso"
15+ scp ./.github/actions/test/integration/test/cloudhypervisor/vm.xml "$IP_HV1:/opt/vm-chv.xml"
16+ scp /opt/ubuntu.raw "$IP_HV1:/var/lib/libvirt/images/ubuntu.raw"
17+ scp /opt/ubuntu-cloud-init-ds.iso "$IP_HV1:/var/lib/libvirt/images/ubuntu-cloud-init-ds.iso"
1818
1919 # libvirt migration between cloudhypervisor instances does not support storage migration yet
20- scp $SSH_OPTS /opt/ubuntu.raw "$USER@ $IP_HV2:/var/lib/libvirt/images/ubuntu.raw"
20+ scp /opt/ubuntu.raw "$IP_HV2:/var/lib/libvirt/images/ubuntu.raw"
2121 # the cloud-init data is not migrated from source to destination, but needed for the VM to run at the destination
22- scp $SSH_OPTS /opt/ubuntu-cloud-init-ds.iso "$USER@ $IP_HV2:/var/lib/libvirt/images/ubuntu-cloud-init-ds.iso"
22+ scp /opt/ubuntu-cloud-init-ds.iso "$IP_HV2:/var/lib/libvirt/images/ubuntu-cloud-init-ds.iso"
2323
2424 - name : Start VM on HyperVisor 1
2525 shell : bash
2626 run : |
27- KEY=/opt/ssh_host_ed25519_key
28- SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
29- USER="root"
3027 IP_HV1="192.168.122.2"
3128
32- ssh $SSH_OPTS "$USER@ $IP_HV1" << EOF
29+ ssh " $IP_HV1" << EOF
3330 virsh -c ch:///session define /opt/vm-chv.xml
3431 virsh -c ch:///session start VM-CHV
3532 EOF
3633
3734 - name : Wait for VM to be ready
3835 shell : bash
3936 run : |
40- KEY=/opt/ssh_host_ed25519_key
41- SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
42- USER="root"
4337 IP_HV1="192.168.122.2"
4438
45- ssh $SSH_OPTS "$USER@$IP_HV1" << EOF
46- KEY=/opt/ssh_host_ed25519_key
47- SSH_OPTS="-i \$KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
48- USER="root"
49-
39+ ssh "$IP_HV1" << EOF
5040 MAX_ITER="${BOOT_MAX_ITER:-60}"
5141 for ((i=1; i<=MAX_ITER; i++)); do
5242 IP=\$(virsh -c ch:///session domifaddr VM-CHV | awk '/ipv4/ {print \$4}' | cut -d'/' -f1)
5343 if [ -z "\$IP" ]; then
5444 echo "No IP address found for VM. Retrying..."
5545 elif (( i >= MAX_ITER - 2 )); then
5646 # Show SSH errors on last 3 attempts for debugging
57- if ssh \$SSH_OPTS "\$USER@ \$IP" 'exit'; then
47+ if ssh " \$IP" 'exit'; then
5848 echo "VM is up at IP: \$IP"
59- ssh \$SSH_OPTS "\$USER@ \$IP" 'echo "Hello, World!" > /opt/hello.txt'
49+ ssh " \$IP" 'echo "Hello, World!" > /opt/hello.txt'
6050 break
6151 fi
62- elif ssh \$SSH_OPTS "\$USER@ \$IP" 'exit' 2>/dev/null; then
52+ elif ssh " \$IP" 'exit' 2>/dev/null; then
6353 echo "VM is up at IP: \$IP"
6454 # create a dummy file for verification later
65- ssh \$SSH_OPTS "\$USER@ \$IP" 'echo "Hello, World!" > /opt/hello.txt'
55+ ssh " \$IP" 'echo "Hello, World!" > /opt/hello.txt'
6656 break
6757 fi
6858 if (( i == MAX_ITER )); then
7767 echo "--- arp -n ---"
7868 arp -n 2>/dev/null || ip neigh || true
7969 echo "--- ssh -v attempt ---"
80- ssh -v \$SSH_OPTS "\$USER@ \$IP" 'exit' 2>&1 || true
70+ ssh -v " \$IP" 'exit' 2>&1 || true
8171 echo "=== END DIAGNOSTICS ==="
8272 exit 1
8373 fi
@@ -86,19 +76,15 @@ runs:
8676 done
8777 EOF
8878
89- - name : Mirgrate the VM to HyperVisor 2
79+ - name : Migrate the VM to HyperVisor 2
9080 shell : bash
9181 run : |
92- KEY=/opt/ssh_host_ed25519_key
93- SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
94- USER="root"
9582 IP_HV1="192.168.122.2"
9683
97- ssh $SSH_OPTS "$USER@$IP_HV1" << EOF
98- USER="root"
84+ ssh "$IP_HV1" << EOF
9985 IP_HV2="192.168.122.3"
10086
101- virsh -c ch:///session migrate --p2p --persistent --undefinesource --live VM-CHV ch+ssh://\$USER @\$IP_HV2/system
87+ virsh -c ch:///session migrate --p2p --persistent --undefinesource --live VM-CHV ch+ssh://root @\$IP_HV2/system
10288 if virsh -c ch:///session dominfo VM-CHV &>/dev/null; then
10389 echo "VM is still present on HV1 after migration!"
10490 exit 1
@@ -108,37 +94,30 @@ runs:
10894 - name : Verify VM status on HyperVisor 2
10995 shell : bash
11096 run : |
111- KEY=/opt/ssh_host_ed25519_key
112- SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
113- USER="root"
11497 IP_HV2="192.168.122.3"
11598
116- ssh $SSH_OPTS "$USER@ $IP_HV2" << EOF
99+ ssh " $IP_HV2" << EOF
117100 if virsh -c ch:///session dominfo VM-CHV | awk '/State:/ {print \$2}' | grep -q "running"; then
118101 echo "VM is running on HV2."
119102 else
120103 echo "VM is not running on HV2."
121104 exit 1
122105 fi
123106
124- KEY=/opt/ssh_host_ed25519_key
125- SSH_OPTS="-i \$KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
126- USER="root"
127107 # waiting for the IP to be visible to the new HyperVisor via DHCP takes WAYYYYYYY too long
128108 # the IP is static, so we can just use it directly
129109 IP="192.168.222.3"
130110
131111 MAX_ITER="${VERIFY_MAX_ITER:-15}"
132112 for ((i=1; i<=MAX_ITER; i++)); do
133- if ssh \$SSH_OPTS "\$USER@ \$IP" 'exit' 2>/dev/null; then
113+ if ssh " \$IP" 'exit' 2>/dev/null; then
134114 echo "VM is up at IP: \$IP"
135115 # verify the migration by checking the dummy file
136- if ssh \$SSH_OPTS "\$USER@ \$IP" 'test -f /opt/hello.txt'; then
116+ if ssh " \$IP" 'test -f /opt/hello.txt'; then
137117 echo "Dummy file exists on VM, migration successful."
138118 break
139119 else
140120 echo "Dummy file does not exist on VM, migration failed."
141- exit 1
142121 fi
143122 fi
144123 if (( i == MAX_ITER )); then
@@ -149,7 +128,7 @@ runs:
149128 echo "--- ip route ---"
150129 ip route || true
151130 echo "--- ssh -v attempt ---"
152- ssh -v \$SSH_OPTS "\$USER@ \$IP" 'exit' 2>&1 || true
131+ ssh -v " \$IP" 'exit' 2>&1 || true
153132 echo "=== END DIAGNOSTICS ==="
154133 exit 1
155134 fi
0 commit comments