[PATCH v3 compass-ci] sparrow: fix containers auto resume failed after reboot

call 4-docker/buildall to fix container auto resume depends issues. Signed-off-by: Liu Yinsi <liuyinsi@163.com> --- sparrow/4-docker/buildall | 26 +++++++++++++++++--------- sparrow/7-systemd/cci-network | 7 +++---- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/sparrow/4-docker/buildall b/sparrow/4-docker/buildall index 230c6ac..26778a4 100755 --- a/sparrow/4-docker/buildall +++ b/sparrow/4-docker/buildall @@ -3,6 +3,7 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. CONTAINER_PATH="$CCI_SRC/container" +export start_only=$1 build_depends() { @@ -30,20 +31,27 @@ do_one() ( cd $container [ "$container_name" == 'sub-fluentd' ] && exit - [ -x build ] && ./build - [ -x install ] && ./install + if [ -z "$start_only" ]; then + [ -x build ] && ./build + [ -x install ] && ./install + fi [ -x first-run ] && ./first-run [ -x start ] && ./start ) lockfile-remove --lock-name "$container_name".lock } -tmpdir=$(mktemp -d) +buildall() +{ + tmpdir=$(mktemp -d) -for dir in $CONTAINER_PATH/*/ -do - build_depends $dir -done + for dir in $CONTAINER_PATH/*/ + do + build_depends $dir + done + + wait + rm -fr $tmpdir +} -wait -rm -fr $tmpdir +buildall diff --git a/sparrow/7-systemd/cci-network b/sparrow/7-systemd/cci-network index 4aadcdc..ef4f3fa 100755 --- a/sparrow/7-systemd/cci-network +++ b/sparrow/7-systemd/cci-network @@ -4,13 +4,12 @@ #this file used in our own systemd unit file: cci-network.service. #contents as follows will be automatically executed after system reboot. -[[ $CCI_SRC ]] || CCI_SRC=/c/compass-ci +# export ENV +. /etc/profile.d/compass.sh $CCI_SRC/sparrow/2-network/br0 $CCI_SRC/sparrow/2-network/iptables $CCI_SRC/sparrow/2-network/nfs $CCI_SRC/sparrow/2-network/cifs -# --restart=always option is not absolutely reliable -containers=($(docker ps -a |grep -v NAMES |awk '{print $NF}')) -[ -n "$containers" ] && docker start "${containers[@]}" >/dev/null 2>&1 +$CCI_SRC/sparrow/4-docker/buildall start_only -- 2.23.0

diff --git a/sparrow/4-docker/buildall b/sparrow/4-docker/buildall index 230c6ac..26778a4 100755 --- a/sparrow/4-docker/buildall +++ b/sparrow/4-docker/buildall @@ -3,6 +3,7 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
CONTAINER_PATH="$CCI_SRC/container" +export start_only=$1
this var name can be "action", to improve the adaption.
build_depends() { @@ -30,20 +31,27 @@ do_one() ( cd $container [ "$container_name" == 'sub-fluentd' ] && exit - [ -x build ] && ./build - [ -x install ] && ./install + if [ -z "$start_only" ]; then
1. start_only => reboot 2. [ -z "$start_only" ] => [ "$action" != "reboot" ]
+ [ -x build ] && ./build + [ -x install ] && ./install + fi [ -x first-run ] && ./first-run [ -x start ] && ./start ) lockfile-remove --lock-name "$container_name".lock }
-tmpdir=$(mktemp -d) +buildall() +{ + tmpdir=$(mktemp -d)
-for dir in $CONTAINER_PATH/*/ -do - build_depends $dir -done + for dir in $CONTAINER_PATH/*/ + do + build_depends $dir + done + + wait + rm -fr $tmpdir +}
-wait -rm -fr $tmpdir +buildall
it seems no need to combine these lines to a function?
diff --git a/sparrow/7-systemd/cci-network b/sparrow/7-systemd/cci-network index 4aadcdc..ef4f3fa 100755 --- a/sparrow/7-systemd/cci-network +++ b/sparrow/7-systemd/cci-network @@ -4,13 +4,12 @@ #this file used in our own systemd unit file: cci-network.service. #contents as follows will be automatically executed after system reboot.
-[[ $CCI_SRC ]] || CCI_SRC=/c/compass-ci +# export ENV +. /etc/profile.d/compass.sh
$CCI_SRC/sparrow/2-network/br0 $CCI_SRC/sparrow/2-network/iptables $CCI_SRC/sparrow/2-network/nfs $CCI_SRC/sparrow/2-network/cifs
-# --restart=always option is not absolutely reliable -containers=($(docker ps -a |grep -v NAMES |awk '{print $NF}')) -[ -n "$containers" ] && docker start "${containers[@]}" >/dev/null 2>&1 +$CCI_SRC/sparrow/4-docker/buildall start_only
^-- start_only => reboot -------- Thanks Yu Chuan
-- 2.23.0

+export start_only=$1
this var name can be "action", to improve the adaption.
ok
build_depends() { @@ -30,20 +31,27 @@ do_one() ( cd $container [ "$container_name" == 'sub-fluentd' ] && exit - [ -x build ] && ./build - [ -x install ] && ./install + if [ -z "$start_only" ]; then
1. start_only => reboot 2. [ -z "$start_only" ] => [ "$action" != "reboot" ]
good
+ [ -x build ] && ./build + [ -x install ] && ./install + fi [ -x first-run ] && ./first-run [ -x start ] && ./start ) lockfile-remove --lock-name "$container_name".lock }
-tmpdir=$(mktemp -d) +buildall() +{ + tmpdir=$(mktemp -d)
-for dir in $CONTAINER_PATH/*/ -do - build_depends $dir -done + for dir in $CONTAINER_PATH/*/ + do + build_depends $dir + done + + wait + rm -fr $tmpdir +}
-wait -rm -fr $tmpdir +buildall
it seems no need to combine these lines to a function?
yes.
diff --git a/sparrow/7-systemd/cci-network b/sparrow/7-systemd/cci-network index 4aadcdc..ef4f3fa 100755 --- a/sparrow/7-systemd/cci-network +++ b/sparrow/7-systemd/cci-network @@ -4,13 +4,12 @@ #this file used in our own systemd unit file: cci-network.service. #contents as follows will be automatically executed after system reboot.
-[[ $CCI_SRC ]] || CCI_SRC=/c/compass-ci +# export ENV +. /etc/profile.d/compass.sh
$CCI_SRC/sparrow/2-network/br0 $CCI_SRC/sparrow/2-network/iptables $CCI_SRC/sparrow/2-network/nfs $CCI_SRC/sparrow/2-network/cifs
-# --restart=always option is not absolutely reliable -containers=($(docker ps -a |grep -v NAMES |awk '{print $NF}')) -[ -n "$containers" ] && docker start "${containers[@]}" >/dev/null 2>&1 +$CCI_SRC/sparrow/4-docker/buildall start_only
^-- start_only => reboot
ok Thanks, Yinsi
-------- Thanks Yu Chuan
-- 2.23.0
participants (2)
-
Liu Yinsi
-
Yu Chuan