potiuk commented on a change in pull request #16503:
URL: https://github.com/apache/airflow/pull/16503#discussion_r655422594



##########
File path: scripts/ci/libraries/_traps.sh
##########
@@ -31,8 +31,17 @@ function traps::add_trap() {
     do
         # adding trap to exiting trap
         local handlers
-        handlers="$( trap -p "${signal}" | cut -f2 -d \' )"
+        # shellcheck disable=SC2046
+        handlers="$(_parse_current_traps "${signal}")"
         # shellcheck disable=SC2064
         trap "${trap};${handlers}" "${signal}"
     done
 }
+
+function _parse_current_traps() {
+  local signal="$1"
+  # Yes, eval is evil, but this is the only way I was able to "parse" the 
output of trap which is "already" quoted
+  eval "set -- $(trap -p "$signal")"

Review comment:
       Yeah. It is insane. I agree. 
   
   Indeed I forgot about cleaning the volume in CI when we separated  it out 
(it's implemented in Breeze). Would be worth checking if test failure results 
with exit != 0. I hope it will fail randomly so we would know ;)

##########
File path: scripts/ci/testing/ci_run_single_airflow_test_in_docker.sh
##########
@@ -100,6 +100,14 @@ function run_airflow_testing_in_docker() {
             # to be set to "root" (GID=0) for the volume to work and this 
cannot be accomplished without sudo
             chmod a+rwx "${MSSQL_DATA_VOLUME}"
             backend_docker_compose+=("-f" 
"${SCRIPTS_CI_DIR}/docker-compose/backend-mssql-bind-volume.yml")
+
+            # Runner user doesn't have blanket sudo access, but we can run 
docker as root. Go figure
+            traps::add_trap "rm -vrf -- '${MSSQL_DATA_VOLUME}'" EXIT

Review comment:
       ```suggestion
               traps::add_trap "rm -vrf -- '${MSSQL_DATA_VOLUME}' || true" EXIT
   ```

##########
File path: scripts/ci/testing/ci_run_single_airflow_test_in_docker.sh
##########
@@ -100,6 +100,14 @@ function run_airflow_testing_in_docker() {
             # to be set to "root" (GID=0) for the volume to work and this 
cannot be accomplished without sudo
             chmod a+rwx "${MSSQL_DATA_VOLUME}"
             backend_docker_compose+=("-f" 
"${SCRIPTS_CI_DIR}/docker-compose/backend-mssql-bind-volume.yml")
+
+            # Runner user doesn't have blanket sudo access, but we can run 
docker as root. Go figure
+            traps::add_trap "rm -vrf -- '${MSSQL_DATA_VOLUME}'" EXIT
+            traps::add_trap "docker run -u 0 --rm -v 
${MSSQL_DATA_VOLUME}:/mssql alpine sh -c 'rm -rvf -- /mssql/*'" EXIT

Review comment:
       ```suggestion
               traps::add_trap "docker run -u 0 --rm -v 
${MSSQL_DATA_VOLUME}:/mssql alpine sh -c 'rm -rvf -- /mssql/*' || true" EXIT
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to