]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/rook: always recreate kvm default network + fix groups refresh 55181/head
authorRedouane Kachach <rkachach@redhat.com>
Mon, 15 Jan 2024 12:41:06 +0000 (13:41 +0100)
committerRedouane Kachach <rkachach@redhat.com>
Wed, 17 Jan 2024 21:55:23 +0000 (22:55 +0100)
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 <rkachach@redhat.com>
src/pybind/mgr/rook/ci/requirements.txt [new file with mode: 0644]
src/pybind/mgr/rook/ci/run-rook-e2e-tests.sh
src/pybind/mgr/rook/ci/scripts/bootstrap-rook-cluster.sh

diff --git a/src/pybind/mgr/rook/ci/requirements.txt b/src/pybind/mgr/rook/ci/requirements.txt
new file mode 100644 (file)
index 0000000..9684f77
--- /dev/null
@@ -0,0 +1 @@
+behave
index a43e01a898617af56dc98cede5a8e739a12a843b..58d55475774f1dca6182fe7e9c6bbd206274e498 100755 (executable)
@@ -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
index 4b97df6bac14ac84375f14d82af69e529d0db130..eb4f9fb66ce725beffe6f242d518ea15876d224c 100755 (executable)
@@ -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