From 11a9fe8947b94cda49a2248c8708552da412485d Mon Sep 17 00:00:00 2001 From: Redouane Kachach Date: Mon, 15 Jan 2024 13:41:06 +0100 Subject: [PATCH] mgr/rook: always recreate kvm default network + fix groups refresh Fixes: https://tracker.ceph.com/issues/64027 This change also includes: - adding ~/.local/bin to path so behave binary can be found - adding requirements.txt file for testing dependencies - increasing timeout used to wait for tools deployment to 90s - increasing timeout used to wait for kvm network to 20s Signed-off-by: Redouane Kachach --- src/pybind/mgr/rook/ci/requirements.txt | 1 + src/pybind/mgr/rook/ci/run-rook-e2e-tests.sh | 3 ++ .../rook/ci/scripts/bootstrap-rook-cluster.sh | 49 +++++++++++++++---- 3 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 src/pybind/mgr/rook/ci/requirements.txt diff --git a/src/pybind/mgr/rook/ci/requirements.txt b/src/pybind/mgr/rook/ci/requirements.txt new file mode 100644 index 00000000000..9684f7742bd --- /dev/null +++ b/src/pybind/mgr/rook/ci/requirements.txt @@ -0,0 +1 @@ +behave diff --git a/src/pybind/mgr/rook/ci/run-rook-e2e-tests.sh b/src/pybind/mgr/rook/ci/run-rook-e2e-tests.sh index a43e01a8986..58d55475774 100755 --- a/src/pybind/mgr/rook/ci/run-rook-e2e-tests.sh +++ b/src/pybind/mgr/rook/ci/run-rook-e2e-tests.sh @@ -2,8 +2,11 @@ set -ex +export PATH=$PATH:~/.local/bin # behave is installed on this directory + # Execute tests : ${CEPH_DEV_FOLDER:=${PWD}} ${CEPH_DEV_FOLDER}/src/pybind/mgr/rook/ci/scripts/bootstrap-rook-cluster.sh cd ${CEPH_DEV_FOLDER}/src/pybind/mgr/rook/ci/tests +pip install --upgrade --force-reinstall -r ../requirements.txt behave diff --git a/src/pybind/mgr/rook/ci/scripts/bootstrap-rook-cluster.sh b/src/pybind/mgr/rook/ci/scripts/bootstrap-rook-cluster.sh index 4b97df6bac1..eb4f9fb66ce 100755 --- a/src/pybind/mgr/rook/ci/scripts/bootstrap-rook-cluster.sh +++ b/src/pybind/mgr/rook/ci/scripts/bootstrap-rook-cluster.sh @@ -15,14 +15,6 @@ on_error() { minikube delete } -configure_libvirt(){ - sudo usermod -aG libvirt $(id -un) - sudo su -l $USER # Avoid having to log out and log in for group addition to take effect. - sudo systemctl enable --now libvirtd - sudo systemctl restart libvirtd - sleep 10 # wait some time for libvirtd service to restart -} - setup_minikube_env() { # Check if Minikube is running @@ -93,7 +85,7 @@ wait_for_ceph_cluster() { local max_attempts=10 local sleep_interval=20 local attempts=0 - $KUBECTL rollout status deployment rook-ceph-tools -n rook-ceph --timeout=30s + $KUBECTL rollout status deployment rook-ceph-tools -n rook-ceph --timeout=90s while ! $KUBECTL get cephclusters.ceph.rook.io -n rook-ceph -o jsonpath='{.items[?(@.kind == "CephCluster")].status.ceph.health}' | grep -q "HEALTH_OK"; do echo "Waiting for Ceph cluster installed" sleep $sleep_interval @@ -118,12 +110,51 @@ show_info() { echo "===========================" } +configure_libvirt(){ + if sudo usermod -aG libvirt $(id -un); then + echo "User added to libvirt group successfully." + sudo systemctl enable --now libvirtd + sudo systemctl restart libvirtd + sleep 10 # wait some time for libvirtd service to restart + newgrp libvirt + else + echo "Error adding user to libvirt group." + return 1 + fi +} + +recreate_default_network(){ + + # destroy any existing kvm default network + if sudo virsh net-destroy default; then + sudo virsh net-undefine default + fi + + # let's create a new kvm default network + sudo virsh net-define /usr/share/libvirt/networks/default.xml + if sudo virsh net-start default; then + echo "Network 'default' started successfully." + else + # Optionally, handle the error + echo "Failed to start network 'default', but continuing..." + fi + + # restart libvirtd service and wait a little bit for the service + sudo systemctl restart libvirtd + sleep 20 + + # Just some debugging information + all_networks=$(virsh net-list --all) + groups=$(groups) +} + #################################################################### #################################################################### trap 'on_error $? $LINENO' ERR configure_libvirt +recreate_default_network setup_minikube_env build_ceph_image create_rook_cluster