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

kaxilnaik pushed a commit to branch v1-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 213500eaebbad06cb6358d63330d7e82803e517b
Author: Jarek Potiuk <jarek.pot...@polidea.com>
AuthorDate: Wed Jul 22 19:54:35 2020 +0200

    Clean up tmp directory when exiting from breeze shell (#9930)
    
    Since we are mountign tmp dir now to inside container, some
    of the remnants of what's going on inside remains after exit.
    This is particularly bad if you are using tmux (some of the
    directories remaining there prevent tmux from re-run)
    
    This change cleans up /tmp directory on exit from Breeze command.
    It does it from inside container so that we clean up all
    root-owned files without sudo.
    
    (cherry picked from commit a9c871b47c017e97374efef64c02fdde9792aff5)
---
 breeze                                              |  1 +
 scripts/ci/in_container/_in_container_utils.sh      | 10 ++++++++++
 scripts/ci/in_container/run_clear_tmp.sh            | 21 +++++++++++++++++++++
 .../tools/{ci_fix_ownership.sh => ci_clear_tmp.sh}  |  5 ++---
 scripts/ci/tools/ci_fix_ownership.sh                |  3 ++-
 5 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/breeze b/breeze
index 27eaee0..91585a1 100755
--- a/breeze
+++ b/breeze
@@ -1963,6 +1963,7 @@ function run_breeze_command {
                 "${BUILD_CACHE_DIR}/${LAST_DC_PROD_FILE}" run --service-ports 
--rm airflow "${@}"
             else
                 "${BUILD_CACHE_DIR}/${LAST_DC_CI_FILE}" run --service-ports 
--rm airflow "${@}"
+                "${SCRIPTS_CI_DIR}/tools/ci_clear_tmp.sh"
             fi
             ;;
         run_exec)
diff --git a/scripts/ci/in_container/_in_container_utils.sh 
b/scripts/ci/in_container/_in_container_utils.sh
index f2e94d4..946bd32 100644
--- a/scripts/ci/in_container/_in_container_utils.sh
+++ b/scripts/ci/in_container/_in_container_utils.sh
@@ -115,6 +115,16 @@ function in_container_fix_ownership() {
     fi
 }
 
+function in_container_clear_tmp() {
+    if [[ ${VERBOSE} == "true" ]]; then
+        echo "Cleaning ${AIRFLOW_SOURCES}/tmp from the container"
+    fi
+    rm -rf /tmp/*
+    if [[ ${VERBOSE} == "true" ]]; then
+        echo "Cleaned ${AIRFLOW_SOURCES}/tmp from the container"
+    fi
+}
+
 function in_container_go_to_airflow_sources() {
     pushd "${AIRFLOW_SOURCES}"  &>/dev/null || exit 1
 }
diff --git a/scripts/ci/in_container/run_clear_tmp.sh 
b/scripts/ci/in_container/run_clear_tmp.sh
new file mode 100755
index 0000000..324a795
--- /dev/null
+++ b/scripts/ci/in_container/run_clear_tmp.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# shellcheck source=scripts/ci/in_container/_in_container_script_init.sh
+. "$( dirname "${BASH_SOURCE[0]}" )/_in_container_script_init.sh"
+
+in_container_clear_tmp
diff --git a/scripts/ci/tools/ci_fix_ownership.sh 
b/scripts/ci/tools/ci_clear_tmp.sh
similarity index 90%
copy from scripts/ci/tools/ci_fix_ownership.sh
copy to scripts/ci/tools/ci_clear_tmp.sh
index 8cde42d..9a8cb4a 100755
--- a/scripts/ci/tools/ci_fix_ownership.sh
+++ b/scripts/ci/tools/ci_clear_tmp.sh
@@ -36,10 +36,9 @@ HOST_OS="$(uname -s)"
 export HOST_USER_ID
 export HOST_GROUP_ID
 export HOST_OS
-export BACKEND="sqlite"
 
 docker-compose \
     -f "${SCRIPTS_CI_DIR}/docker-compose/base.yml" \
     -f "${SCRIPTS_CI_DIR}/docker-compose/local.yml" \
-    -f "${SCRIPTS_CI_DIR}/docker-compose/forward-credentials.yml" \
-    run airflow /opt/airflow/scripts/ci/in_container/run_fix_ownership.sh
+   run --entrypoint /bin/bash \
+    airflow -c /opt/airflow/scripts/ci/in_container/run_clear_tmp.sh
diff --git a/scripts/ci/tools/ci_fix_ownership.sh 
b/scripts/ci/tools/ci_fix_ownership.sh
index 8cde42d..d3ae4ba 100755
--- a/scripts/ci/tools/ci_fix_ownership.sh
+++ b/scripts/ci/tools/ci_fix_ownership.sh
@@ -42,4 +42,5 @@ docker-compose \
     -f "${SCRIPTS_CI_DIR}/docker-compose/base.yml" \
     -f "${SCRIPTS_CI_DIR}/docker-compose/local.yml" \
     -f "${SCRIPTS_CI_DIR}/docker-compose/forward-credentials.yml" \
-    run airflow /opt/airflow/scripts/ci/in_container/run_fix_ownership.sh
+    run --entrypoint /bin/bash \
+    airflow -c /opt/airflow/scripts/ci/in_container/run_fix_ownership.sh

Reply via email to