create finished file to track finished shells

This commit is contained in:
Heavybullets8 2022-08-21 17:54:10 -06:00
parent fe8c9b0553
commit 846ea6011e

View File

@ -13,7 +13,7 @@ pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{pri
it=0 it=0
while_count=0 while_count=0
rm deploying 2>/dev/null rm deploying 2>/dev/null
rm all_app_status 2>/dev/null rm finished 2>/dev/null
while true while true
do do
if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; 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
@ -50,13 +50,14 @@ do
((it++)) ((it++))
# ((loop++)) # ((loop++))
# done # done
elif [[ $proc_count != 0 ]] || grep -qs ",DEPLOYING," all_app_status 2>/dev/null ; then # Wait for all processes to finish elif [[ $proc_count != 0 || $(wc -l finished 2>/dev/null | awk '{ print $1 }') -lt "${#array[@]}" ]]; then # Wait for all processes to finish
sleep 3 sleep 3
else # All processes must be completed, break out of loop else # All processes must be completed, break out of loop
break break
fi fi
done done
rm deploying 2>/dev/null rm deploying 2>/dev/null
rm finished 2>/dev/null
echo echo
echo echo
} }
@ -65,7 +66,7 @@ export -f commander
pre_process(){ pre_process(){
app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name.
printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && final_check && return 0 #If application is on ignore list, skip
old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version
new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version
old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version
@ -73,7 +74,7 @@ new_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{pr
startstatus=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE startstatus=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE
diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions
diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions
[[ "$diff_app" != "$diff_chart" && $update_apps == "true" ]] && echo -e "\n$app_name\nMajor Release, update manually" && return [[ "$diff_app" != "$diff_chart" && $update_apps == "true" ]] && echo -e "\n$app_name\nMajor Release, update manually" && final_check && return
old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From
new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To
rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}')
@ -82,6 +83,7 @@ if grep -qs "^$app_name," failed 2>/dev/null; then
if [[ "$failed_ver" == "$new_full_ver" ]] ; then if [[ "$failed_ver" == "$new_full_ver" ]] ; then
echo -e "\n$app_name" echo -e "\n$app_name"
echo -e "Skipping previously failed version:\n$new_full_ver" echo -e "Skipping previously failed version:\n$new_full_ver"
final_check
return 0 return 0
else else
sed -i /"$app_name",/d failed sed -i /"$app_name",/d failed
@ -105,6 +107,7 @@ if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # C
else else
echo_array+=("Error: Failed to stop $app_name") echo_array+=("Error: Failed to stop $app_name")
echo_array echo_array
final_check
return 1 return 1
fi fi
fi fi
@ -114,13 +117,16 @@ if update_app ;then
else else
echo_array+=("Failed to update") echo_array+=("Failed to update")
echo_array echo_array
final_check
return return
fi fi
if grep -qs "^$app_name,true" external_services ; then if grep -qs "^$app_name,true" external_services ; then
echo_array echo_array
final_check
return return
else else
after_update_actions after_update_actions
final_check
fi fi
} }
export -f pre_process export -f pre_process
@ -275,3 +281,8 @@ done
} }
export -f echo_array export -f echo_array
final_check(){
[[ ! -e finished ]] && touch finished
echo "$app_name,finished" >> finished
}