[PATCH v3 compass-ci] container: expose/report error when check modules exist

[why] sparrow/2-network/nfs: modprobe nfs modprobe nfsd sparrow/2-network/cifs: modprobe cifs when locally deploy compass-ci, the above codes have modprobe nfs, nfsd, cifs, no need to do again when execute sparrow/4-docker/buildall(deploy containers), exit and report error message to function callers is better. Signed-off-by: Liu Yinsi <liuyinsi@163.com> --- container/initrd-cifs/start | 4 +++- container/os-cifs/start | 4 +++- container/os-nfs/start | 7 +++++-- container/result-cifs/start | 4 +++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/container/initrd-cifs/start b/container/initrd-cifs/start index 77558a1..119d1b1 100755 --- a/container/initrd-cifs/start +++ b/container/initrd-cifs/start @@ -3,9 +3,11 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. . $CCI_SRC/container/defconfig.sh +. $LKP_SRC/lib/log.sh lsmod | grep -q "^cifs\s" || { - sudo modprobe cifs + log_error "[ERROR] kernel module cifs is missing (try: sudo modprobe cifs)" + exit 1 } docker_rm initrd-cifs diff --git a/container/os-cifs/start b/container/os-cifs/start index 5e08238..47da260 100755 --- a/container/os-cifs/start +++ b/container/os-cifs/start @@ -3,9 +3,11 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. . $CCI_SRC/container/defconfig.sh +. $LKP_SRC/lib/log.sh lsmod | grep -q "^cifs\s" || { - sudo modprobe cifs + log_error "[ERROR] kernel module cifs is missing (try: sudo modprobe cifs)" + exit 1 } docker_rm os-cifs diff --git a/container/os-nfs/start b/container/os-nfs/start index 8b8ff5f..8c08db8 100755 --- a/container/os-nfs/start +++ b/container/os-nfs/start @@ -3,12 +3,15 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. . $CCI_SRC/container/defconfig.sh +. $LKP_SRC/lib/log.sh lsmod | grep -q "^nfs\s" || { - sudo modprobe nfs + log_error "[ERROR] kernel module nfs is missing (try: sudo modprobe nfs)" + exit 1 } lsmod | grep -q "^nfsd\s" || { - sudo modprobe nfsd + log_error "[ERROR] kernel module nfsd is missing (try: sudo modprobe nfsd)" + exit 1 } # Several nfs servers running will cause conflict, so rm an old before running a new nfs server docker. diff --git a/container/result-cifs/start b/container/result-cifs/start index 2d6acba..4f8c2b9 100755 --- a/container/result-cifs/start +++ b/container/result-cifs/start @@ -3,9 +3,11 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. . $CCI_SRC/container/defconfig.sh +. $LKP_SRC/lib/log.sh lsmod | grep -q "^cifs\s" || { - sudo modprobe cifs + log_error "[ERROR] kernel module cifs is missing (try: sudo modprobe cifs)" + exit 1 } docker_rm result-cifs -- 2.23.0

On Wed, Jan 27, 2021 at 06:14:44PM +0800, Liu Yinsi wrote:
[why] sparrow/2-network/nfs: modprobe nfs modprobe nfsd
sparrow/2-network/cifs: modprobe cifs
when locally deploy compass-ci, the above codes have modprobe nfs, nfsd, cifs, no need to do again when execute sparrow/4-docker/buildall(deploy containers), exit and report error message to function callers is better.
Signed-off-by: Liu Yinsi <liuyinsi@163.com> --- container/initrd-cifs/start | 4 +++- container/os-cifs/start | 4 +++- container/os-nfs/start | 7 +++++-- container/result-cifs/start | 4 +++- 4 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/container/initrd-cifs/start b/container/initrd-cifs/start index 77558a1..119d1b1 100755 --- a/container/initrd-cifs/start +++ b/container/initrd-cifs/start @@ -3,9 +3,11 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
. $CCI_SRC/container/defconfig.sh +. $LKP_SRC/lib/log.sh
lsmod | grep -q "^cifs\s" || { - sudo modprobe cifs + log_error "[ERROR] kernel module cifs is missing (try: sudo modprobe cifs)"
About function: log_error "$message": '[ERROR]' is no need in $message, it already be in $LKP_SRC/lib/log.sh log_error() { echo "$(date +'%F %T') [ERROR] -- $*" >&2 } And the below code have the same problem. -------- Thanks Yu Chuan
+ exit 1 }
docker_rm initrd-cifs diff --git a/container/os-cifs/start b/container/os-cifs/start index 5e08238..47da260 100755 --- a/container/os-cifs/start +++ b/container/os-cifs/start @@ -3,9 +3,11 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
. $CCI_SRC/container/defconfig.sh +. $LKP_SRC/lib/log.sh
lsmod | grep -q "^cifs\s" || { - sudo modprobe cifs + log_error "[ERROR] kernel module cifs is missing (try: sudo modprobe cifs)" + exit 1 }
docker_rm os-cifs diff --git a/container/os-nfs/start b/container/os-nfs/start index 8b8ff5f..8c08db8 100755 --- a/container/os-nfs/start +++ b/container/os-nfs/start @@ -3,12 +3,15 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
. $CCI_SRC/container/defconfig.sh +. $LKP_SRC/lib/log.sh
lsmod | grep -q "^nfs\s" || { - sudo modprobe nfs + log_error "[ERROR] kernel module nfs is missing (try: sudo modprobe nfs)" + exit 1 } lsmod | grep -q "^nfsd\s" || { - sudo modprobe nfsd + log_error "[ERROR] kernel module nfsd is missing (try: sudo modprobe nfsd)" + exit 1 }
# Several nfs servers running will cause conflict, so rm an old before running a new nfs server docker. diff --git a/container/result-cifs/start b/container/result-cifs/start index 2d6acba..4f8c2b9 100755 --- a/container/result-cifs/start +++ b/container/result-cifs/start @@ -3,9 +3,11 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
. $CCI_SRC/container/defconfig.sh +. $LKP_SRC/lib/log.sh
lsmod | grep -q "^cifs\s" || { - sudo modprobe cifs + log_error "[ERROR] kernel module cifs is missing (try: sudo modprobe cifs)" + exit 1 }
docker_rm result-cifs -- 2.23.0

lsmod | grep -q "^cifs\s" || { - sudo modprobe cifs + log_error "[ERROR] kernel module cifs is missing (try: sudo modprobe cifs)"
About function: log_error "$message": '[ERROR]' is no need in $message, it already be in $LKP_SRC/lib/log.sh
log_error() { echo "$(date +'%F %T') [ERROR] -- $*" >&2 }
And the below code have the same problem.
OK. Thanks, Yinsi
-------- Thanks Yu Chuan
+ exit 1 }
docker_rm initrd-cifs diff --git a/container/os-cifs/start b/container/os-cifs/start index 5e08238..47da260 100755 --- a/container/os-cifs/start +++ b/container/os-cifs/start @@ -3,9 +3,11 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
. $CCI_SRC/container/defconfig.sh +. $LKP_SRC/lib/log.sh
lsmod | grep -q "^cifs\s" || { - sudo modprobe cifs + log_error "[ERROR] kernel module cifs is missing (try: sudo modprobe cifs)" + exit 1 }
docker_rm os-cifs diff --git a/container/os-nfs/start b/container/os-nfs/start index 8b8ff5f..8c08db8 100755 --- a/container/os-nfs/start +++ b/container/os-nfs/start @@ -3,12 +3,15 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
. $CCI_SRC/container/defconfig.sh +. $LKP_SRC/lib/log.sh
lsmod | grep -q "^nfs\s" || { - sudo modprobe nfs + log_error "[ERROR] kernel module nfs is missing (try: sudo modprobe nfs)" + exit 1 } lsmod | grep -q "^nfsd\s" || { - sudo modprobe nfsd + log_error "[ERROR] kernel module nfsd is missing (try: sudo modprobe nfsd)" + exit 1 }
# Several nfs servers running will cause conflict, so rm an old before running a new nfs server docker. diff --git a/container/result-cifs/start b/container/result-cifs/start index 2d6acba..4f8c2b9 100755 --- a/container/result-cifs/start +++ b/container/result-cifs/start @@ -3,9 +3,11 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
. $CCI_SRC/container/defconfig.sh +. $LKP_SRC/lib/log.sh
lsmod | grep -q "^cifs\s" || { - sudo modprobe cifs + log_error "[ERROR] kernel module cifs is missing (try: sudo modprobe cifs)" + exit 1 }
docker_rm result-cifs -- 2.23.0
participants (2)
-
Liu Yinsi
-
Yu Chuan