Skip to content

Commit

Permalink
CI: Enable software-emulation for nested VMs
Browse files Browse the repository at this point in the history
Signed-off-by: Kiefer Chang <kiefer.chang@suse.com>
  • Loading branch information
bk201 committed Feb 14, 2023
1 parent 7f18994 commit a239d26
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ci/run_vagrant_install_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@
debug:
msg: "{{ setup_harvester_result.stdout_lines }}"

- name: Enable software-emulation in KubeVirt
register: kubevirt_result
vars:
settings_file: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-harvester/settings.yml"
shell: >
./enable_soft_emulation.sh {{ settings_file }}
args:
chdir: "{{ WORKSPACE }}/harvester-installer/ci/terraform"

- name: Print Enable software-emulation in KubeVirt output
debug:
msg: "{{ kubevirt_result.stdout_lines }}"

- name: Clear the previous temp file
shell: >
./cleanup_test_files.sh
Expand Down
19 changes: 19 additions & 0 deletions ci/terraform/enable_soft_emulation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash -ex

if [[ $# != 1 ]]
then
echo "We need the settings.yaml from ipxe repo"
exit 1
fi

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/" &> /dev/null && pwd )"
IN_SCRIPT_DIR=$SCRIPT_DIR/in-scripts

SETTINGS=$1
SSHKEY="$SCRIPT_DIR/tmp-ssh-key"
NODE0_IP=$(yq e ".harvester_network_config.cluster[0].ip" ${SETTINGS})

ssh-keygen -R ${NODE0_IP} || true

scp -i ${SSHKEY} $IN_SCRIPT_DIR/patch-kubevirt.sh rancher@$NODE0_IP:/tmp/
ssh -i ${SSHKEY} rancher@$NODE0_IP sudo -i /tmp/patch-kubevirt.sh
34 changes: 34 additions & 0 deletions ci/terraform/in-scripts/patch-kubevirt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash -ex

wait_kubevirt() {
# Wait for kubevirt to be deployed
namespace=$1
name=$2

echo "Waiting for KubeVirt to be deployed..."
while [ true ]; do
kubevirt=$(kubectl get kubevirts.kubevirt.io $name -n $namespace -o yaml)

current_phase=$(echo "$kubevirt" | yq e '.status.phase' -)
if [ "$current_phase" = "Deployed" ]; then
echo "KubeVirt is deployed"
break
fi

echo "KubeVirt current phase: $current_phase"
sleep 5
done
}

MANIFEST=$(mktemp --suffix=.yml)
trap "rm -f $MANIFEST" EXIT

cat >$MANIFEST<<EOF
spec:
configuration:
developerConfiguration:
useEmulation: true
EOF

kubectl patch kubevirts.kubevirt.io/kubevirt -n harvester-system --patch-file $MANIFEST --type merge
wait_kubevirt harvester-system kubevirt

0 comments on commit a239d26

Please sign in to comment.