Remove parallel requests improvement, because it's buggy in some situations...

Revert #979b6ca0c83ce743c3867d1f0315624359f704de
This commit is contained in:
Tortue Torche 2021-09-15 17:05:25 +02:00
parent c96de32f7e
commit b287b7f16f
2 changed files with 16 additions and 9 deletions

View File

@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Changed
- Remove parallel requests improvement, because it's buggy in some situations...
## [1.3.0-alpha] - 2021-09-14 ## [1.3.0-alpha] - 2021-09-14
### Changed ### Changed
- **Breaking Change**: [HTTPie](https://httpie.io/) is replaced by [cURL](https://curl.se), for smaller Docker images, faster execution and to be more portable - **Breaking Change**: [HTTPie](https://httpie.io/) is replaced by [cURL](https://curl.se), for smaller Docker images, faster execution and to be more portable

20
psu
View File

@ -185,7 +185,7 @@ main() {
# or desired state == 'shutdown' and state == 'complete' # or desired state == 'shutdown' and state == 'complete'
# Tasks should not have one of these states: # Tasks should not have one of these states:
# 'failed', 'orphaned', 'remove' # 'failed', 'orphaned', 'remove'
timeout "$TIMEOUT" bash -c "until (export PORTAINER_SERVICE_NAME=$PORTAINER_SERVICE_NAME && psu --action=tasks:healthy --quiet --debug=false --verbose=false) >/dev/null 2>&1; do echo -n \$(if [ \"\$VERBOSE_MODE\" == \"true\" ]; then echo -n .; fi) && sleep 1; done;" timeout "$TIMEOUT" bash -c "until (export HTTPIE_VERIFY_SSL=$HTTPIE_VERIFY_SSL && export PORTAINER_SERVICE_NAME=$PORTAINER_SERVICE_NAME && export PORTAINER_AUTH_TOKEN=$PORTAINER_AUTH_TOKEN && export PORTAINER_URL=$PORTAINER_URL && export PORTAINER_STACK_NAME=$PORTAINER_STACK_NAME && export DEBUG_MODE=false && export VERBOSE_MODE=false && psu --action tasks:healthy --quiet) >/dev/null 2>&1; do echo -n \$(if [ \"$VERBOSE_MODE\" == \"true\" ]; then echo -n .; fi) && sleep 1; done;"
status=$? status=$?
if $(exit $status); then if $(exit $status); then
@ -208,14 +208,18 @@ main() {
echo_debug "Tasks action response -> $(echo $tasks | jq -C .)" echo_debug "Tasks action response -> $(echo $tasks | jq -C .)"
else else
echo_verbose "List $scope tasks of stack '$PORTAINER_STACK_NAME'..." echo_verbose "List $scope tasks of stack '$PORTAINER_STACK_NAME'..."
# Boost performance with parallel requests local services
# See: https://stackoverflow.com/questions/8634109/parallel-download-using-curl-command-line-utility#comment51239188_24276040 services="$(timeout "$TIMEOUT" bash -c "until (export HTTPIE_VERIFY_SSL=$HTTPIE_VERIFY_SSL && export PORTAINER_AUTH_TOKEN=$PORTAINER_AUTH_TOKEN && export PORTAINER_URL=$PORTAINER_URL && export PORTAINER_STACK_NAME=$PORTAINER_STACK_NAME && export DEBUG_MODE=false && export VERBOSE_MODE=false && echo \"\$(psu --action services --quiet)\"); do sleep 1; done;")"
local tasks_action for service in $services; do
tasks_action="$(if [ "$scope" == "healthy" ]; then echo "tasks:healthy"; else echo "tasks"; fi)" export PORTAINER_SERVICE_NAME=${service#"${PORTAINER_STACK_NAME}_"}
local new_tasks local new_tasks
new_tasks=$(psu --action=services --quiet --debug=false --verbose=false | sed "s/^${PORTAINER_STACK_NAME}_\(.*\)$/\1/" | \ new_tasks=$(if [ "$scope" == "healthy" ]; then tasks_healthy; else tasks; fi)
xargs -I "{}" -P 10 -- psu --action="$tasks_action" --service={} --quiet=false --debug=false --verbose=false) if [ -z "$new_tasks" ] || [ "$new_tasks" == "[]" ]; then
tasks="$(echo "$new_tasks" | jq -sjc 'add | unique_by(.ID)')" echo_verbose "Error: $scope tasks aren't running correctly for the stack \"$PORTAINER_STACK_NAME\""
exit 1;
fi
tasks="$(echo "${tasks}${new_tasks}" | jq -sjc 'add | unique_by(.ID)')"
done
echo_debug "Tasks action response -> $(echo $tasks | jq -C .)" echo_debug "Tasks action response -> $(echo $tasks | jq -C .)"
fi fi