revert to original method +2 at a time

This commit is contained in:
Heavybullets8 2022-08-10 21:46:08 -06:00
parent 2bf137fbc5
commit 31285a8d68

View File

@ -10,23 +10,64 @@ echo "Asynchronous Updates: $update_limit"
[[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips"
# previous 20% 2 min 9 seconds # previous 20% 2 min 9 seconds
it=0 # it=0
while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) # while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null)
echo "$while_status" > temp.txt # echo "$while_status" > temp.txt
rm trigger &>/dev/null # rm trigger &>/dev/null
delay=2 # delay=2
# final_check=0
# while true
# do
# if [[ -f trigger ]]; then
# delay=4
# if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then
# echo "$while_status" > temp.txt
# else
# echo "Middlewared timed out. Consider setting a lower number for async applications"
# continue
# fi
# fi
# proc_count=${#processes[@]}
# count=0
# for proc in "${processes[@]}"
# do
# kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); }
# ((count++))
# done
# if [[ "$proc_count" -ge "$update_limit" ]]; then
# sleep $delay
# elif [[ $it -lt ${#array[@]} ]]; then
# until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]]
# do
# update_apps "${array[$it]}" &
# processes+=($!)
# sleep 4
# ((it++))
# ((proc_count++))
# done
# elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish
# sleep $delay
# else # All processes must be completed, break out of loop
# [[ $final_check == 0 ]] && ((final_check++)) && continue
# break
# fi
# done
# rm temp.txt
# [[ -f trigger ]] && rm trigger
# echo
# echo
final_check=0 final_check=0
it=0
while true while true
do do
if [[ -f trigger ]]; then if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then
delay=4 echo "$while_status" > temp.txt
if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then else
echo "$while_status" > temp.txt echo "Middlewared timed out. Consider setting a lower number for async applications"
else continue
echo "Middlewared timed out. Consider setting a lower number for async applications"
continue
fi
fi fi
echo "$while_status" > temp.txt
proc_count=${#processes[@]} proc_count=${#processes[@]}
count=0 count=0
for proc in "${processes[@]}" for proc in "${processes[@]}"
@ -35,27 +76,26 @@ do
((count++)) ((count++))
done done
if [[ "$proc_count" -ge "$update_limit" ]]; then if [[ "$proc_count" -ge "$update_limit" ]]; then
sleep $delay sleep 3
elif [[ $it -lt ${#array[@]} ]]; then elif [[ $it -lt ${#array[@]} ]]; then
until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] until [[ "$proc_count" -ge 2 || $it -ge ${#array[@]} ]];
do do
update_apps "${array[$it]}" & update_apps "${array[$it]}" &
processes+=($!) processes+=($!)
sleep 4
((it++))
((proc_count++)) ((proc_count++))
((it++))
done done
elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish
sleep $delay sleep 3
else # All processes must be completed, break out of loop else # All processes must be completed, break out of loop
[[ $final_check == 0 ]] && ((final_check++)) && continue [[ $final_check == 0 ]] && ((final_check++)) && continue
break break
fi fi
done done
rm temp.txt rm temp.txt
[[ -f trigger ]] && rm trigger
echo echo
echo echo
} }
export -f commander export -f commander
@ -99,7 +139,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con
[[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..")
midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || echo_array+=("Error: Failed to stop $app_name") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || echo_array+=("Error: Failed to stop $app_name")
SECONDS=0 SECONDS=0
[[ ! -e trigger ]] && touch trigger # [[ ! -e trigger ]] && touch trigger
while [[ "$status" != "STOPPED" ]] while [[ "$status" != "STOPPED" ]]
do do
status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}')
@ -147,7 +187,7 @@ do
update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}')
if [[ $update_avail == "true" ]]; then if [[ $update_avail == "true" ]]; then
if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then
[[ ! -e trigger ]] && touch trigger && sleep 10 # [[ ! -e trigger ]] && touch trigger && sleep 10
sleep 6 sleep 6
((count++)) ((count++))
continue continue
@ -167,7 +207,7 @@ after_update_actions(){
SECONDS=0 SECONDS=0
count=0 count=0
if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then
[[ ! -e trigger ]] && touch trigger && sleep 10 # [[ ! -e trigger ]] && touch trigger && sleep 10
while true while true
do do
(( count++ )) (( count++ ))