diff --git a/internal/task/scripts/collect.go b/internal/task/scripts/collect.go deleted file mode 100644 index 0e2ee5114..000000000 --- a/internal/task/scripts/collect.go +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2021 NetEase Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Project: CurveAdm - * Created Date: 2021-11-26 - * Author: Jingli Chen (Wine93) - */ - -package scripts - -/* - * Usage: collect PREFIX CONTAINER_ID DEST_DIR - * Example: collect /usr/local/curvefs/etcd 8d9b0c0bdec5 /tmp/dest_dir - */ -var COLLECT = ` -############################ GLOBAL VARIABLES -g_prefix="$1" -g_container_id="$2" -g_dest_dir="$3" -g_log_dir="$g_prefix/logs" -g_conf_dir="$g_prefix/conf" - -############################ FUNCTIONS -function docker_cmd() { - sudo docker exec $g_container_id /bin/bash -c "$1" -} - -function docker_cp() { - sudo docker cp $g_container_id:$1 $2 -} - -function copy_logs() { - sudo docker logs $g_container_id > $g_dest_dir/logs/stdout - sudo docker logs $g_container_id 2> $g_dest_dir/logs/stderr - for file in $(docker_cmd "ls $g_log_dir | tail -n 5") - do - docker_cp $g_log_dir/$file $g_dest_dir/logs - done -} - -function copy_config() { - docker_cp $g_conf_dir $g_dest_dir -} - -function main() { - mkdir -p $g_dest_dir/{logs,conf} - copy_logs - copy_config -} - -############################ MAIN() -main "$@" -` diff --git a/internal/task/scripts/create_volume.go b/internal/task/scripts/create_volume.go deleted file mode 100644 index 765054ccc..000000000 --- a/internal/task/scripts/create_volume.go +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2022 NetEase Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Project: CurveAdm - * Created Date: 2022-07-31 - * Author: Jingli Chen (Wine93) - */ - -package scripts - -/* - * Usage: create_volume USER VOLUME SIZE - * Example: create_volume curve test 10 - */ -var CREATE_VOLUME = ` -#!/usr/bin/env bash - -g_user=$1 -g_volume=$2 -g_size=$3 - -output=$(curve_ops_tool create -userName=$g_user -fileName=$g_volume -fileLength=$g_size) -if [ $? -ne 0 ]; then - if [ "$output" = "CreateFile fail with errCode: 101" ]; then - echo "EXIST" - else - echo "FAILED" - fi -else - echo "SUCCESS" -fi -` diff --git a/internal/task/scripts/createfs.go b/internal/task/scripts/createfs.go deleted file mode 100644 index 211d35249..000000000 --- a/internal/task/scripts/createfs.go +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2022 NetEase Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Project: CurveAdm - * Created Date: 2022-01-04 - * Author: chengyi01 - */ - -package scripts - -/* - * Usage: create fs before mount fs - * Example: createfs /test - */ -var CREATEFS = ` -g_curvefs_tool="curvefs_tool" -g_curvefs_tool_operator="create-fs" -g_rpc_timeout_ms="-rpcTimeoutMs=10000" -g_fsname="-fsName=" -g_fstype="-fsType=" -g_entrypoint="/entrypoint.sh" - -function createfs() { - g_fsname=$g_fsname$1 - g_fstype=$g_fstype$2 - - $g_curvefs_tool $g_curvefs_tool_operator $g_fsname $g_fstype $g_rpc_timeout_ms -} - -createfs "$@" - -ret=$? -if [ $ret -eq 0 ]; then - $g_entrypoint "$@" - ret=$? - exit $ret -else - echo "CREATEFS FAILED" - exit 1 -fi -` diff --git a/internal/task/scripts/format.go b/internal/task/scripts/format.go deleted file mode 100644 index 826fcf137..000000000 --- a/internal/task/scripts/format.go +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2021 NetEase Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Project: CurveAdm - * Created Date: 2021-12-27 - * Author: Jingli Chen (Wine93) - */ - -package scripts - -var FORMAT = ` -binary=$1 -percent=$2 -chunkfile_size=$3 -chunkfile_pool_dir=$4 -chunkfile_pool_meta_path=$5 - -mkdir -p $chunkfile_pool_dir -$binary \ - -allocatePercent=$percent \ - -fileSize=$chunkfile_size \ - -filePoolDir=$chunkfile_pool_dir \ - -filePoolMetaPath=$chunkfile_pool_meta_path \ - -fileSystemPath=$chunkfile_pool_dir -` diff --git a/internal/task/scripts/map.go b/internal/task/scripts/map.go deleted file mode 100644 index f6cedea15..000000000 --- a/internal/task/scripts/map.go +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2021 NetEase Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Project: CurveAdm - * Created Date: 2022-01-10 - * Author: Jingli Chen (Wine93) - */ - -package scripts - -/* - * Usage: map USER VOLUME CREATE SIZE - * Example: map curve test true 10 - */ -var MAP = ` -#!/usr/bin/env bash - -g_user=$1 -g_volume=$2 -g_options=$3 -g_stderr=/tmp/__curveadm_map__ - -mkdir -p /curvebs/nebd/data/lock -touch /etc/curve/curvetab -curve-nbd map --nbds_max=16 ${g_options} cbd:pool/${g_volume}_${g_user}_ > ${g_stderr} 2>&1 -if [ $? -ne 0 ]; then - cat ${g_stderr} - exit 1 -else - echo "SUCCESS" -fi -` diff --git a/internal/task/scripts/nginx.go b/internal/task/scripts/nginx.go deleted file mode 100644 index d7cfcb762..000000000 --- a/internal/task/scripts/nginx.go +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2022 NetEase Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Project: CurveAdm - * Created Date: 2022-08-09 - * Author: Jingli Chen (Wine93) - */ - -package scripts - -var START_NGINX = ` -g_listen="$1" - -cat << __EOF__ > /etc/nginx/nginx.conf -daemon off; -events { - worker_connections 768; -} -http { - server { - $g_listen - } -} -__EOF__ - -nginx -` diff --git a/internal/task/scripts/recycle.go b/internal/task/scripts/recycle.go deleted file mode 100644 index 3dfe5c2b2..000000000 --- a/internal/task/scripts/recycle.go +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2021 NetEase Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Project: CurveAdm - * Created Date: 2022-01-13 - * Author: Jingli Chen (Wine93) - */ - -package scripts - -/* - * Usage: recycle SOURCE DESTINATION SIZE - * Example: recycle '/data/chunkserver0/copysets /data/chunkserver0/recycler' /data/chunkserver0/chunkfilepool 16781312 - */ -var RECYCLE = ` -g_source=$1 -g_dest=$2 -g_size=$3 -chunkid=$(ls -vr ${g_dest} | head -n 1) -chunkid=${chunkid%.clean} -for file in $(find $g_source -type f -size ${g_size}c -printf '%p\n'); do - chunkid=$((chunkid+1)) - mv $file $g_dest/$chunkid -done -` diff --git a/internal/task/scripts/script.go b/internal/task/scripts/script.go index 1cd4c6e1c..51bcc9813 100644 --- a/internal/task/scripts/script.go +++ b/internal/task/scripts/script.go @@ -22,6 +22,10 @@ package scripts +import ( + _ "embed" +) + const ( STATUS_OK = "CURVEADM_OK" STATUS_FAIL = "CURVEADM_FAIL" @@ -29,15 +33,32 @@ const ( ) var ( - SCRIPT_WAIT string = WAIT - SCRIPT_COLLECT string = COLLECT - SCRIPT_REPORT string = REPORT - SCRIPT_FORMAT string = FORMAT - SCRIPT_MAP string = MAP - SCRIPT_TARGET string = TARGET - SCRIPT_RECYCLE string = RECYCLE - SCRIPT_CREATEFS string = CREATEFS - SCRIPT_CREATE_VOLUME string = CREATE_VOLUME - SCRIPT_WAIT_CHUNKSERVERS string = WAIT_CHUNKSERVERS - SCRIPT_START_NGINX string = START_NGINX + // Common + + //go:embed shell/wait.sh + WAIT string + //go:embed shell/report.sh + REPORT string + + // CurveBS + + //go:embed shell/format.sh + FORMAT string + //go:embed shell/wait_chunkserver.sh + WAIT_CHUNKSERVERS string + //go:embed shell/start_nginx.sh + START_NGINX string + //go:embed shell/create_volume.sh + CREATE_VOLUME string + //go:embed shell/map.sh + MAP string + //go:embed shell/target.sh + TARGET string + //go:embed shell/recycle.sh + RECYCLE string + + // CurveFS + + //go:embed shell/create_fs.sh + CREATE_FS string ) diff --git a/internal/task/scripts/shell/create_fs.sh b/internal/task/scripts/shell/create_fs.sh new file mode 100644 index 000000000..718ea9724 --- /dev/null +++ b/internal/task/scripts/shell/create_fs.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# Usage: create_fs USER VOLUME SIZE +# Example: create_fs curve test 10 +# Created Date: 2022-01-04 +# Author: chengyi01 + + +g_curvefs_tool="curvefs_tool" +g_curvefs_tool_operator="create-fs" +g_rpc_timeout_ms="-rpcTimeoutMs=10000" +g_fsname="-fsName=" +g_fstype="-fsType=" +g_entrypoint="/entrypoint.sh" + +function createfs() { + g_fsname=$g_fsname$1 + g_fstype=$g_fstype$2 + + $g_curvefs_tool $g_curvefs_tool_operator "$g_fsname" "$g_fstype" $g_rpc_timeout_ms +} + +createfs "$@" + +ret=$? +if [ $ret -eq 0 ]; then + $g_entrypoint "$@" + ret=$? + exit $ret +else + echo "CREATEFS FAILED" + exit 1 +fi diff --git a/internal/task/scripts/shell/create_volume.sh b/internal/task/scripts/shell/create_volume.sh new file mode 100644 index 000000000..2983f787d --- /dev/null +++ b/internal/task/scripts/shell/create_volume.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Usage: create_volume USER VOLUME SIZE +# Example: create_volume curve test 10 +# Created Date: 2022-07-31 +# Author: Jingli Chen (Wine93) + + +g_user=$1 +g_volume=$2 +g_size=$3 + +output=$(curve_ops_tool create -userName="$g_user" -fileName="$g_volume" -fileLength="$g_size") +if [ $? -ne 0 ]; then + if [ "$output" = "CreateFile fail with errCode: 101" ]; then + echo "EXIST" + else + echo "FAILED" + fi +else + echo "SUCCESS" +fi diff --git a/internal/task/scripts/shell/format.sh b/internal/task/scripts/shell/format.sh new file mode 100644 index 000000000..635b5eb69 --- /dev/null +++ b/internal/task/scripts/shell/format.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +# Created Date: 2021-12-27 +# Author: Jingli Chen (Wine93) + + +binary=$1 +percent=$2 +chunkfile_size=$3 +chunkfile_pool_dir=$4 +chunkfile_pool_meta_path=$5 + +mkdir -p $chunkfile_pool_dir +$binary \ + -allocatePercent=$percent \ + -fileSize=$chunkfile_size \ + -filePoolDir=$chunkfile_pool_dir \ + -filePoolMetaPath=$chunkfile_pool_meta_path \ + -fileSystemPath=$chunkfile_pool_dir diff --git a/internal/task/scripts/shell/map.sh b/internal/task/scripts/shell/map.sh new file mode 100644 index 000000000..3a23b5133 --- /dev/null +++ b/internal/task/scripts/shell/map.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Usage: map USER VOLUME CREATE SIZE +# Example: map curve test true 10 +# Created Date: 2022-01-10 +# Author: Jingli Chen (Wine93) + + +g_user=$1 +g_volume=$2 +g_options=$3 +g_stderr=/tmp/__curveadm_map__ + +mkdir -p /curvebs/nebd/data/lock +touch /etc/curve/curvetab +curve-nbd map --nbds_max=16 ${g_options} cbd:pool/${g_volume}_${g_user}_ > ${g_stderr} 2>&1 +if [ $? -ne 0 ]; then + cat ${g_stderr} + exit 1 +else + echo "SUCCESS" +fi diff --git a/internal/task/scripts/shell/recycle.sh b/internal/task/scripts/shell/recycle.sh new file mode 100644 index 000000000..c4e7bba8c --- /dev/null +++ b/internal/task/scripts/shell/recycle.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# Usage: recycle SOURCE DESTINATION SIZE +# Example: recycle '/data/chunkserver0/copysets /data/chunkserver0/recycler' /data/chunkserver0/chunkfilepool 16781312 +# Created Date: 2022-01-13 +# Author: Jingli Chen (Wine93) + + +g_source=$1 +g_dest=$2 +g_size=$3 +chunkid=$(ls -vr ${g_dest} | head -n 1) +chunkid=${chunkid%.clean} +for file in $(find $g_source -type f -size ${g_size}c -printf '%p\n'); do + chunkid=$((chunkid+1)) + mv $file $g_dest/$chunkid +done diff --git a/internal/task/scripts/report.go b/internal/task/scripts/shell/report.sh similarity index 52% rename from internal/task/scripts/report.go rename to internal/task/scripts/shell/report.sh index f6a8f179c..a7fedeaa9 100644 --- a/internal/task/scripts/report.go +++ b/internal/task/scripts/shell/report.sh @@ -1,32 +1,11 @@ -/* - * Copyright (c) 2021 NetEase Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +#!/usr/bin/env bash -/* - * Project: CurveAdm - * Created Date: 2021-12-06 - * Author: Jingli Chen (Wine93) - */ +# Usage: report KIND UUID ROLE +# Example: report curvebs abcdef01234567890 metaserver +# Created Date: 2021-12-06 +# Author: Jingli Chen (Wine93) -package scripts -/* - * Usage: report KIND UUID ROLE - * Example: report curvebs abcdef01234567890 metaserver - */ -var REPORT = ` function rematch() { local s=$1 regex=$2 if [[ $s =~ $regex ]]; then @@ -41,7 +20,7 @@ function fs_usage() { BYTES["GB"] = BYTES["MB"] * 1024 BYTES["TB"] = BYTES["GB"] * 1024 } - { + { if ($0 ~ /all cluster/) { printf ("%0.f", $8 * BYTES[$9]) } @@ -64,4 +43,3 @@ curl -XPOST http://curveadm.aspirer.wang:19302/ \ -d "uuid=$g_uuid" \ -d "role=$g_role" \ -d "usage=$g_usage" -` diff --git a/internal/task/scripts/shell/start_nginx.sh b/internal/task/scripts/shell/start_nginx.sh new file mode 100644 index 000000000..a0888f9fa --- /dev/null +++ b/internal/task/scripts/shell/start_nginx.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# Created Date: 2022-08-09 +# Author: Jingli Chen (Wine93) + + +g_listen="$1" + +cat << __EOF__ > /etc/nginx/nginx.conf +daemon off; +events { + worker_connections 768; +} +http { + server { + $g_listen + } +} +__EOF__ + +nginx diff --git a/internal/task/scripts/target.go b/internal/task/scripts/shell/target.sh similarity index 64% rename from internal/task/scripts/target.go rename to internal/task/scripts/shell/target.sh index 5767f8540..82d564a86 100644 --- a/internal/task/scripts/target.go +++ b/internal/task/scripts/shell/target.sh @@ -1,35 +1,11 @@ -/* - * Copyright (c) 2021 NetEase Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Project: CurveAdm - * Created Date: 2022-02-08 - * Author: Jingli Chen (Wine93) - */ - -package scripts +#!/usr/bin/env bash -/* - * Usage: target USER VOLUME CREATE SIZE - * Example: target curve test true 10 - * See Also: https://linux.die.net/man/8/tgtadm - */ +# Usage: target USER VOLUME CREATE SIZE +# Example: target curve test true 10 +# See Also: https://linux.die.net/man/8/tgtadm +# Created Date: 2022-02-08 +# Author: Jingli Chen (Wine93) -var TARGET = ` -#!/usr/bin/env bash g_user=$1 g_volume=$2 @@ -103,4 +79,3 @@ if [ $? -ne 0 ]; then echo "tgtadm target bind failed" exit 1 fi -` diff --git a/internal/task/scripts/shell/wait.sh b/internal/task/scripts/shell/wait.sh new file mode 100644 index 000000000..41c1c5fbb --- /dev/null +++ b/internal/task/scripts/shell/wait.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Usage: wait ADDR... +# Example: wait 10.0.10.1:2379 10.0.10.2:2379 +# Created Date: 2021-11-25 +# Author: Jingli Chen (Wine93) + + +[[ -z $(which curl) ]] && apt-get install -y curl +wait=0 +while ((wait<20)) +do + for addr in "$@" + do + curl --connect-timeout 3 --max-time 10 $addr -Iso /dev/null + if [ $? == 0 ]; then + exit 0 + fi + done + sleep 0.5s + wait=$(expr $wait + 1) +done +echo "wait timeout" +exit 1 diff --git a/internal/task/scripts/shell/wait_chunkserver.sh b/internal/task/scripts/shell/wait_chunkserver.sh new file mode 100644 index 000000000..e62f91fd0 --- /dev/null +++ b/internal/task/scripts/shell/wait_chunkserver.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Usage: no args, just run it in bash +# Created Date: 2022-03-09 +# Author: aspirer + + +# FIXME(P0): wait not works, return -12 +wait=0 +while ((wait<60)) +do + status=$(curve_ops_tool chunkserver-status |grep "offline") + total=$(echo ${status} | grep -c "total num = 0") + offline=$(echo ${status} | grep -c "offline = 0") + if [ ${total} -eq 0 ] && [ ${offline} -eq 1 ]; then + echo "CURVEADM_SUCCESS" + exit 0 + fi + sleep 0.5s + wait=$(expr ${wait} + 1) +done +echo "CURVEADM_TIMEOUT" +exit 1 diff --git a/internal/task/scripts/wait.go b/internal/task/scripts/wait.go deleted file mode 100644 index 838ee2c46..000000000 --- a/internal/task/scripts/wait.go +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2021 NetEase Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Project: CurveAdm - * Created Date: 2021-11-25 - * Author: Jingli Chen (Wine93) - */ - -package scripts - -/* - * Usage: wait ADDR... - * Example: wait 10.0.10.1:2379 10.0.10.2:2379 - */ -var WAIT = ` -[[ -z $(which curl) ]] && apt-get install -y curl -wait=0 -while ((wait<20)) -do - for addr in "$@" - do - curl --connect-timeout 3 --max-time 10 $addr -Iso /dev/null - if [ $? == 0 ]; then - exit 0 - fi - done - sleep 0.5s - wait=$(expr $wait + 1) -done -echo "wait timeout" -exit 1 -` diff --git a/internal/task/scripts/wait_chunkservers.go b/internal/task/scripts/wait_chunkservers.go deleted file mode 100644 index 15109190b..000000000 --- a/internal/task/scripts/wait_chunkservers.go +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2022 NetEase Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Project: CurveAdm - * Created Date: 2022-03-09 - * Author: aspirer - */ - -package scripts - -/* - * Usage: no args, just run it in bash - */ -// FIXME(P0): wait not works, return -12 -var WAIT_CHUNKSERVERS = ` -wait=0 -while ((wait<60)) -do - status=$(curve_ops_tool chunkserver-status |grep "offline") - total=$(echo ${status} | grep -c "total num = 0") - offline=$(echo ${status} | grep -c "offline = 0") - if [ ${total} -eq 0 ] && [ ${offline} -eq 1 ]; then - echo "CURVEADM_SUCCESS" - exit 0 - fi - sleep 0.5s - wait=$(expr ${wait} + 1) -done -echo "CURVEADM_TIMEOUT" -exit 1 -` diff --git a/internal/task/task/bs/format.go b/internal/task/task/bs/format.go index cc2291407..769d2759d 100644 --- a/internal/task/task/bs/format.go +++ b/internal/task/task/bs/format.go @@ -186,7 +186,7 @@ func NewFormatChunkfilePoolTask(curveadm *cli.CurveAdm, fc *configure.FormatConf containerName := device2ContainerName(device) layout := topology.GetCurveBSProjectLayout() chunkfilePoolRootDir := layout.ChunkfilePoolRootDir - formatScript := scripts.SCRIPT_FORMAT + formatScript := scripts.FORMAT formatScriptPath := fmt.Sprintf("%s/format.sh", layout.ToolsBinDir) formatCommand := fmt.Sprintf("%s %s %d %d %s %s", formatScriptPath, layout.FormatBinaryPath, usagePercent, DEFAULT_CHUNKFILE_SIZE, layout.ChunkfilePoolDir, layout.ChunkfilePoolMetaPath) diff --git a/internal/task/task/common/clean_service.go b/internal/task/task/common/clean_service.go index 825a962e6..3c9b75117 100644 --- a/internal/task/task/common/clean_service.go +++ b/internal/task/task/common/clean_service.go @@ -155,7 +155,7 @@ func NewCleanServiceTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*ta // add step to task clean := utils.Slice2Map(only) files := getCleanFiles(clean, dc, recycle) // directorys which need cleaned - recyleScript := scripts.SCRIPT_RECYCLE + recyleScript := scripts.RECYCLE recyleScriptPath := utils.RandFilename(TEMP_DIR) if dc.GetKind() == topology.KIND_CURVEBS { diff --git a/internal/task/task/common/collect_service.go b/internal/task/task/common/collect_service.go index 19698aa13..75460d2ca 100644 --- a/internal/task/task/common/collect_service.go +++ b/internal/task/task/common/collect_service.go @@ -24,6 +24,8 @@ package common import ( "fmt" + "path" + "github.com/opencurve/curveadm/cli/cli" comm "github.com/opencurve/curveadm/internal/common" "github.com/opencurve/curveadm/internal/configure/topology" @@ -32,7 +34,6 @@ import ( "github.com/opencurve/curveadm/internal/task/task" tui "github.com/opencurve/curveadm/internal/tui/common" "github.com/opencurve/curveadm/internal/utils" - "path" ) const ( diff --git a/internal/task/task/common/create_pool.go b/internal/task/task/common/create_pool.go index 02c017a01..62a85062f 100644 --- a/internal/task/task/common/create_pool.go +++ b/internal/task/task/common/create_pool.go @@ -199,7 +199,7 @@ func NewCreateTopologyTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (* host, role := dc.GetHost(), dc.GetRole() layout := dc.GetProjectLayout() poolJSONPath := fmt.Sprintf("%s/topology.json", layout.ToolsConfDir) - waitScript := scripts.SCRIPT_WAIT + waitScript := scripts.WAIT waitScriptPath := fmt.Sprintf("%s/wait.sh", layout.ToolsBinDir) clusterPoolJson, clusterMDSAddrs, err := prepare(curveadm, dc) if err != nil { @@ -242,7 +242,7 @@ func NewCreateTopologyTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (* }) if dc.GetKind() == topology.KIND_CURVEBS && pooltype == comm.POOL_TYPE_LOGICAL { - waitChunkserversScript := scripts.SCRIPT_WAIT_CHUNKSERVERS + waitChunkserversScript := scripts.WAIT_CHUNKSERVERS waitChunkserversScriptPath := fmt.Sprintf("%s/wait_chunkservers.sh", layout.ToolsBinDir) t.AddStep(&step.InstallFile{ // install wait_chunkservers script ContainerId: &containerId, diff --git a/internal/task/task/common/sync_config.go b/internal/task/task/common/sync_config.go index 2090f5f84..b1a674e5d 100644 --- a/internal/task/task/common/sync_config.go +++ b/internal/task/task/common/sync_config.go @@ -108,7 +108,7 @@ func NewSyncConfigTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) (*task var out string layout := dc.GetProjectLayout() role := dc.GetRole() - reportScript := scripts.SCRIPT_REPORT + reportScript := scripts.REPORT reportScriptPath := fmt.Sprintf("%s/report.sh", layout.ToolsBinDir) crontab := newCrontab(curveadm.ClusterUUId(), dc, reportScriptPath) delimiter := DEFAULT_CONFIG_DELIMITER diff --git a/internal/task/task/fs/mount.go b/internal/task/task/fs/mount.go index 0d3ac588b..920f01067 100644 --- a/internal/task/task/fs/mount.go +++ b/internal/task/task/fs/mount.go @@ -291,7 +291,7 @@ func NewMountFSTask(curveadm *cli.CurveAdm, cc *configure.ClientConfig) (*task.T prefix := configure.GetFSClientPrefix() containerMountPath := configure.GetFSClientMountPath(mountPoint) containerName := mountPoint2ContainerName(mountPoint) - createfsScript := scripts.SCRIPT_CREATEFS + createfsScript := scripts.CREATE_FS createfsScriptPath := "/client.sh" t.AddStep(&step.DockerInfo{