Merge pull request #27 from Heavybullets8/remove-proc-count-var
- Parse exceptions before going through update loop
This commit is contained in:
commit
fe2c4520a3
@ -9,11 +9,48 @@ echo "Asynchronous Updates: $update_limit"
|
|||||||
[[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout"
|
[[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout"
|
||||||
[[ "$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"
|
||||||
pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r")
|
pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r")
|
||||||
it=0
|
|
||||||
|
index=0
|
||||||
|
for app in "${array[@]}"
|
||||||
|
do
|
||||||
|
app_name=$(echo "$app" | awk -F ',' '{print $1}') #print out first catagory, name.
|
||||||
|
old_app_ver=$(echo "$app" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version
|
||||||
|
new_app_ver=$(echo "$app" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version
|
||||||
|
old_chart_ver=$(echo "$app" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version
|
||||||
|
new_chart_ver=$(echo "$app" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version
|
||||||
|
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
|
||||||
|
|
||||||
|
#Skip application if its on ignore list
|
||||||
|
if printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" ; then
|
||||||
|
echo -e "\n$app_name\nIgnored, skipping"
|
||||||
|
unset "array[$index]"
|
||||||
|
#Skip appliaction if major update and not ignoreing major versions
|
||||||
|
elif [[ "$diff_app" != "$diff_chart" && $update_apps == "true" ]] ; then
|
||||||
|
echo -e "\n$app_name\nMajor Release, update manually"
|
||||||
|
unset "array[$index]"
|
||||||
|
# Skip update if application previously failed on this exact update version
|
||||||
|
elif grep -qs "^$app_name," failed 2>/dev/null; then
|
||||||
|
failed_ver=$(grep "^$app_name," failed | awk -F ',' '{print $2}')
|
||||||
|
if [[ "$failed_ver" == "$new_full_ver" ]] ; then
|
||||||
|
echo -e "\n$app_name"
|
||||||
|
echo -e "Skipping previously failed version:\n$new_full_ver"
|
||||||
|
else
|
||||||
|
sed -i /"$app_name",/d failed
|
||||||
|
fi
|
||||||
|
unset "array[$index]"
|
||||||
|
fi
|
||||||
|
((index++))
|
||||||
|
done
|
||||||
|
array=("${array[@]}")
|
||||||
|
[[ ${#array[@]} == 0 ]] && echo && echo && return
|
||||||
|
|
||||||
|
|
||||||
|
index=0
|
||||||
while_count=0
|
while_count=0
|
||||||
rm deploying 2>/dev/null
|
rm deploying 2>/dev/null
|
||||||
rm finished 2>/dev/null
|
rm finished 2>/dev/null
|
||||||
while [[ $proc_count != 0 || $(wc -l finished 2>/dev/null | awk '{ print $1 }') -lt "${#array[@]}" ]]
|
while [[ ${#processes[@]} != 0 || $(wc -l finished 2>/dev/null | awk '{ print $1 }') -lt "${#array[@]}" ]]
|
||||||
do
|
do
|
||||||
if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' 2>/dev/null) ; then
|
if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' 2>/dev/null) ; then
|
||||||
((while_count++))
|
((while_count++))
|
||||||
@ -31,17 +68,17 @@ do
|
|||||||
echo "Middlewared timed out. Consider setting a lower number for async applications"
|
echo "Middlewared timed out. Consider setting a lower number for async applications"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
proc_count=${#processes[@]}
|
|
||||||
count=0
|
count=0
|
||||||
for proc in "${processes[@]}"
|
for proc in "${processes[@]}"
|
||||||
do
|
do
|
||||||
kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); }
|
kill -0 "$proc" &> /dev/null || unset "processes[$count]"
|
||||||
((count++))
|
((count++))
|
||||||
done
|
done
|
||||||
if [[ $it -lt ${#array[@]} && "$proc_count" -lt "$update_limit" ]]; then
|
processes=("${processes[@]}")
|
||||||
pre_process "${array[$it]}" &
|
if [[ $index -lt ${#array[@]} && "${#processes[@]}" -lt "$update_limit" ]]; then
|
||||||
|
pre_process "${array[$index]}" &
|
||||||
processes+=($!)
|
processes+=($!)
|
||||||
((it++))
|
((index++))
|
||||||
else
|
else
|
||||||
sleep 3
|
sleep 3
|
||||||
fi
|
fi
|
||||||
@ -55,32 +92,12 @@ 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[$index]}" | awk -F ',' '{print $1}') #print out first catagory, name.
|
||||||
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
|
startstatus=$(echo "${array[$index]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE
|
||||||
old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version
|
old_full_ver=$(echo "${array[$index]}" | awk -F ',' '{print $4}') #Upgraded From
|
||||||
new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version
|
new_full_ver=$(echo "${array[$index]}" | awk -F ',' '{print $5}') #Upraded To
|
||||||
old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version
|
rollback_version=$(echo "${array[$index]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}')
|
||||||
new_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version
|
|
||||||
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_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" && final_check && return
|
|
||||||
old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From
|
|
||||||
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}')
|
|
||||||
|
|
||||||
# Skip update if application previously failed on this exact update version
|
|
||||||
if grep -qs "^$app_name," failed 2>/dev/null; then
|
|
||||||
failed_ver=$(grep "^$app_name," failed | awk -F ',' '{print $2}')
|
|
||||||
if [[ "$failed_ver" == "$new_full_ver" ]] ; then
|
|
||||||
echo -e "\n$app_name"
|
|
||||||
echo -e "Skipping previously failed version:\n$new_full_ver"
|
|
||||||
final_check
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
sed -i /"$app_name",/d failed
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if app is external services, append outcome to external_services file
|
# Check if app is external services, append outcome to external_services file
|
||||||
[[ ! -e external_services ]] && touch external_services
|
[[ ! -e external_services ]] && touch external_services
|
||||||
@ -191,13 +208,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then
|
|||||||
fi
|
fi
|
||||||
elif [[ "$SECONDS" -ge "$timeout" ]]; then
|
elif [[ "$SECONDS" -ge "$timeout" ]]; then
|
||||||
if [[ $rollback == "true" ]]; then
|
if [[ $rollback == "true" ]]; then
|
||||||
if [[ $old_full_ver == "$new_full_ver" ]]; then
|
if [[ "$failed" != "true" ]]; then
|
||||||
echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)")
|
|
||||||
echo_array+=("This is the result of a container image update..")
|
|
||||||
echo_array+=("Reverting is not possible, Abandoning")
|
|
||||||
echo_array
|
|
||||||
return 1
|
|
||||||
elif [[ "$failed" != "true" ]]; then
|
|
||||||
echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)")
|
echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)")
|
||||||
echo_array+=("If this is a slow starting application, set a higher timeout with -t")
|
echo_array+=("If this is a slow starting application, set a higher timeout with -t")
|
||||||
echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration")
|
echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration")
|
||||||
|
Loading…
Reference in New Issue
Block a user