You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2021/06/22 19:25:17 UTC

[airflow] 39/47: Stop showing output of a parallel job once it has finished. (#16528)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v2-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 5e697d34269749926c08d87febd43f963d1622c1
Author: Ash Berlin-Taylor <as...@firemirror.com>
AuthorDate: Fri Jun 18 18:58:40 2021 +0100

    Stop showing output of a parallel job once it has finished. (#16528)
    
    If you are running this manually/locally you get a lot of "extra" output
    which makes it harder to see what jobs are still actually running.
    
    (cherry picked from commit 8a090dc097da18a7d94e912cab8cec8b88ac4396)
---
 scripts/ci/libraries/_parallel.sh | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/scripts/ci/libraries/_parallel.sh b/scripts/ci/libraries/_parallel.sh
index 03e910c..f81fee0 100644
--- a/scripts/ci/libraries/_parallel.sh
+++ b/scripts/ci/libraries/_parallel.sh
@@ -60,6 +60,10 @@ function parallel::monitor_loop() {
     local progress_report_number=1
     local start_time
     local end_time
+    # To continue supporting Bash v3 we can't use associative arrays - so use a
+    # normal array and just check if the value is in it -- it will only ever be
+    # a few items long so it won't be too expensive
+    declare -a finished_jobs=()
     start_time=${SECONDS}
     while true
     do
@@ -72,12 +76,30 @@ function parallel::monitor_loop() {
         for directory in "${PARALLEL_MONITORED_DIR}"/*/*
         do
             parallel_process=$(basename "${directory}")
+            if ( IFS=$'\x1F';  [[ "$IFS${finished_jobs[*]}$IFS" == *"$IFS${parallel_process}$IFS"* ]] ) ; then
+              # Already finished, so don't print anything
+              continue
+            fi
 
             echo "${COLOR_BLUE}### The last lines for ${parallel_process} process: ${directory}/stdout ###${COLOR_RESET}"
             echo
             tail -2 "${directory}/stdout" || true
             echo
+
+            if [[ -s "${directory}/status" ]]; then
+              finished_jobs+=("$parallel_process")
+              status=$(cat "${directory}/status")
+
+              if [[ $status == 0 ]]; then
+                local color="$COLOR_GREEN"
+              else
+                local color="$COLOR_RED"
+              fi
+              echo "${color}### Test ${parallel_process} exited with ${status}${COLOR_RESET}"
+            fi
+
             echo
+
         done
         echo
         echo "${COLOR_YELLOW}########### Monitoring progress end: ${progress_report_number} #################${COLOR_RESET}"