iSulad/0086-move-reinstall_thinpool-to-helper.sh.patch
WangFengTu b1ffa045c4 iSulad: sync with upstream iSulad
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
2021-05-18 14:48:15 +08:00

193 lines
6.2 KiB
Diff

From a86e5ede7866a18c681ab95d83cc3ae875a71930 Mon Sep 17 00:00:00 2001
From: gaohuatao <gaohuatao@huawei.com>
Date: Mon, 26 Apr 2021 10:09:46 +0800
Subject: [PATCH 086/104] move reinstall_thinpool to helper.sh
Signed-off-by: gaohuatao <gaohuatao@huawei.com>
---
.../container_cases/graph_root_test.sh | 38 ---------
.../container_cases/storage_opts_dm.sh | 30 -------
CI/test_cases/helpers.sh | 79 +++++++++++++++++++
3 files changed, 79 insertions(+), 68 deletions(-)
diff --git a/CI/test_cases/container_cases/graph_root_test.sh b/CI/test_cases/container_cases/graph_root_test.sh
index 678d176e..4beb5d9e 100644
--- a/CI/test_cases/container_cases/graph_root_test.sh
+++ b/CI/test_cases/container_cases/graph_root_test.sh
@@ -22,44 +22,6 @@
declare -r curr_path=$(dirname $(readlink -f "$0"))
source ../helpers.sh
-function reinstall_thinpool()
-{
- local ret=0
-
- cat /etc/isulad/daemon.json | grep driver | grep devicemapper
- if [[ $? -ne 0 ]]; then
- return ${ret}
- fi
-
- dev_disk=`pvs | grep isulad | awk '{print$1}'`
- rm -rf /var/lib/isulad/*
- dmsetup remove_all
- lvremove -f isulad/thinpool
- lvremove -f isulad/thinpoolmeta
- vgremove -f isulad
- pvremove -f $dev_disk
- mount | grep $dev_disk | grep /var/lib/isulad
- if [ x"$?" == x"0" ]; then
- umount /var/lib/isulad
- fi
- touch /etc/lvm/profile/isulad-thinpool.profile
- cat > /etc/lvm/profile/isulad-thinpool.profile <<EOF
-activation {
-thin_pool_autoextend_threshold=80
-thin_pool_autoextend_percent=20
-}
-EOF
- echo y | mkfs.ext4 $dev_disk
- pvcreate -y $dev_disk
- vgcreate isulad $dev_disk
- echo y | lvcreate --wipesignatures y -n thinpool isulad -l 80%VG
- echo y | lvcreate --wipesignatures y -n thinpoolmeta isulad -l 1%VG
- lvconvert -y --zero n -c 512K --thinpool isulad/thinpool --poolmetadata isulad/thinpoolmeta
- lvchange --metadataprofile isulad-thinpool isulad/thinpool
- lvs -o+seg_monitor
- return ${ret}
-}
-
function test_run_root_dir_realpath()
{
local ret=0
diff --git a/CI/test_cases/container_cases/storage_opts_dm.sh b/CI/test_cases/container_cases/storage_opts_dm.sh
index e0f476fe..c90eab7a 100755
--- a/CI/test_cases/container_cases/storage_opts_dm.sh
+++ b/CI/test_cases/container_cases/storage_opts_dm.sh
@@ -24,36 +24,6 @@ data_path=$(realpath $curr_path/../data)
source ../helpers.sh
image_busybox="busybox"
-function reinstall_thinpool()
-{
- dev_disk=`pvs | grep isulad | awk '{print$1}'`
- rm -rf /var/lib/isulad/*
- dmsetup remove_all
- lvremove -f isulad/thinpool
- lvremove -f isulad/thinpoolmeta
- vgremove -f isulad
- pvremove -f $dev_disk
- mount | grep $dev_disk | grep /var/lib/isulad
- if [ x"$?" == x"0" ]; then
- umount /var/lib/isulad
- fi
- touch /etc/lvm/profile/isulad-thinpool.profile
- cat > /etc/lvm/profile/isulad-thinpool.profile <<EOF
-activation {
-thin_pool_autoextend_threshold=80
-thin_pool_autoextend_percent=20
-}
-EOF
- echo y | mkfs.ext4 $dev_disk
- pvcreate -y $dev_disk
- vgcreate isulad $dev_disk
- echo y | lvcreate --wipesignatures y -n thinpool isulad -l 80%VG
- echo y | lvcreate --wipesignatures y -n thinpoolmeta isulad -l 1%VG
- lvconvert -y --zero n -c 512K --thinpool isulad/thinpool --poolmetadata isulad/thinpoolmeta
- lvchange --metadataprofile isulad-thinpool isulad/thinpool
- lvs -o+seg_monitor
-}
-
function do_pre()
{
local ret=0
diff --git a/CI/test_cases/helpers.sh b/CI/test_cases/helpers.sh
index fe256e8c..7f4a286d 100755
--- a/CI/test_cases/helpers.sh
+++ b/CI/test_cases/helpers.sh
@@ -191,3 +191,82 @@ function init_cni_conf()
return $TC_RET_T
}
+
+function do_install_thinpool()
+{
+ local ret=0
+
+ dev_disk=`pvs | grep isulad | awk '{print$1}'`
+ rm -rf /var/lib/isulad/*
+ dmsetup remove_all
+ lvremove -f isulad/thinpool
+ lvremove -f isulad/thinpoolmeta
+ vgremove -f isulad
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - vgremove failed" && ((ret++))
+
+ pvremove -f $dev_disk
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - pvremove failed" && ((ret++))
+
+ mount | grep $dev_disk | grep /var/lib/isulad
+ if [ x"$?" == x"0" ]; then
+ umount /var/lib/isulad
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - umount isulad failed" && ((ret++))
+ fi
+ touch /etc/lvm/profile/isulad-thinpool.profile
+ cat > /etc/lvm/profile/isulad-thinpool.profile <<EOF
+activation {
+thin_pool_autoextend_threshold=80
+thin_pool_autoextend_percent=20
+}
+EOF
+ echo y | mkfs.ext4 $dev_disk
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - mkfs.ext4 $dev_disk failed" && ((ret++))
+
+ pvcreate -y $dev_disk
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - vgremove isulad failed" && ((ret++))
+
+ vgcreate isulad $dev_disk
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - vgremove isulad failed" && ((ret++))
+
+ echo y | lvcreate --wipesignatures y -n thinpool isulad -l 80%VG
+ echo y | lvcreate --wipesignatures y -n thinpoolmeta isulad -l 1%VG
+
+ dmsetup status | grep -w "isulad-thinpoolmeta"
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - isulad-thinpoolmeta: no such device" && ((ret++))
+
+ dmsetup status | grep -w "isulad-thinpool"
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - isulad-thinpool: no such device" && ((ret++))
+
+ lvconvert -y --zero n -c 512K --thinpool isulad/thinpool --poolmetadata isulad/thinpoolmeta
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - lvconvert failed" && ((ret++))
+
+ lvchange --metadataprofile isulad-thinpool isulad/thinpool
+ [[ $? -ne 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - lvchange failed" && ((ret++))
+
+ lvs -o+seg_monitor
+
+ return $ret
+}
+
+# Delete all containers and stop isulad before executing this func
+function reinstall_thinpool()
+{
+ retry_limit=3
+ retry_interval=2
+ state="fail"
+
+ for i in $(seq 1 "$retry_limit"); do
+ do_install_thinpool
+ if [ $? -eq 0 ]; then
+ state="success"
+ break;
+ fi
+ sleep $retry_interval
+ done
+
+ if [ "$state" != "success" ]; then
+ return 1
+ fi
+ return 0
+}
+
--
2.25.1