Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
修改删除pod等待脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
liu-657667 committed Dec 5, 2023
1 parent e92b986 commit 7f72904
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,52 @@ jobs:
run: |
kubectl get module
- name: exist module more then 1
run: |
moduleCount=$(kubectl get module | wc -l)
echo $moduleCount
if [[ $moduleCount -lt 1 ]]; then
echo "ERROR: 未达到指定module数量"
exit 1
fi
- name: batch scaleup then wait module available
run: |
# 定义要等待的资源类型和期望的字段值
moduletype="module"
desired_field_value="Available"
# 定义等待的超时时间(以秒为单位)
timeout_seconds=300
start_time=$(date +%s)
end_time=$((start_time + timeout_seconds))
while true; do
current_time=$(date +%s)
if [ $current_time -gt $end_time ]; then
echo "等待超时"
exit 1
fi
# 获取所有的资源对象名,并循环处理
for modulename in $(kubectl get $moduletype -o name); do
# 使用 kubectl get 命令获取每个资源对象的详细信息,并提取自定义字段的值
field_value=$(kubectl get $modulename -o custom-columns=STATUS:.status.status --no-headers)
# 检查字段值是否满足期望
if [ "$field_value" != "$desired_field_value" ]; then
echo "等待字段值满足条件..."
sleep 5 # 等待一段时间后再次检查
continue 2 # 如果字段值未满足,则跳出循环,进入下一轮等待
fi
done
# 如果所有资源对象的字段值都满足期望,则结束脚本
echo "字段值已满足条件"
exit 0
done
- name: check moduledeployment pause
run: |
# 定义要等待的资源名称和字段值
Expand Down

0 comments on commit 7f72904

Please sign in to comment.