From b9d11922f7ba4f300a478fbcc3c460ad0da6f46a Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Tue, 5 Oct 2021 02:05:13 +0200 Subject: [PATCH] Fix compatibility issues with docker-compose 2 (#18725) Docker-compose 2 on linux introduced a number of problems and incompatibilities: * version is printed in different format * -f flag was failing after --log-level info was passed * environment variables were not correctly passed with _docker.env with missing values All those worked fine in 1.29.2 and even in MacOS version of docker-compose 2 (after raising and fixing some bugs by us docker/compose-cli#1917 This PR: * fixes version regexp * removes --log-level info * adds copy of _docker.env with var="${var} assignments specifically for docker-compose (duplicated variables but this works as a workaround) GitOrigin-RevId: 2630341d0f5088215798719a5418a3e77abbc5c7 --- breeze | 2 +- scripts/ci/docker-compose/_docker_compose.env | 49 +++++++++++++++++++ scripts/ci/docker-compose/base.yml | 2 +- .../ci_run_single_airflow_test_in_docker.sh | 2 +- 4 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 scripts/ci/docker-compose/_docker_compose.env diff --git a/breeze b/breeze index f3a44f4b138..0d81de4d7e6 100755 --- a/breeze +++ b/breeze @@ -593,7 +593,7 @@ function breeze::prepare_command_file() { cat <"${file}" #!/usr/bin/env bash docker_compose_version=\$(docker-compose --version || true) -if [[ \${docker_compose_version} =~ .*([0-9]+)\.([0-9]+)\.([0-9]+).+ ]]; then +if [[ \${docker_compose_version} =~ .*([0-9]+)\.([0-9]+)\.([0-9]+).* ]]; then major=\${BASH_REMATCH[1]} minor=\${BASH_REMATCH[2]} patch=\${BASH_REMATCH[3]} diff --git a/scripts/ci/docker-compose/_docker_compose.env b/scripts/ci/docker-compose/_docker_compose.env new file mode 100644 index 00000000000..d206af47d0f --- /dev/null +++ b/scripts/ci/docker-compose/_docker_compose.env @@ -0,0 +1,49 @@ +AIRFLOW_CI_IMAGE="${AIRFLOW_CI_IMAGE}" +AIRFLOW_EXTRAS="${AIRFLOW_EXTRAS}" +BACKEND="${BACKEND}" +BREEZE="${BREEZE}" +CI="${CI}" +CI_BUILD_ID="${CI_BUILD_ID}" +CI_JOB_ID="${CI_JOB_ID}" +CI_EVENT_TYPE="${CI_EVENT_TYPE}" +CI_TARGET_REPO="${CI_TARGET_REPO}" +CI_TARGET_BRANCH="${CI_TARGET_BRANCH}" +COMMIT_SHA="${COMMIT_SHA}" +DB_RESET="${DB_RESET}" +DEFAULT_BRANCH="${DEFAULT_BRANCH}" +DEFAULT_CONSTRAINTS_BRANCH="${DEFAULT_CONSTRAINTS_BRANCH}" +ENABLED_INTEGRATIONS="${ENABLED_INTEGRATIONS}" +ENABLED_SYSTEMS="${ENABLED_SYSTEMS}" +GITHUB_ACTIONS="${GITHUB_ACTIONS}" +GITHUB_REGISTRY_PULL_IMAGE_TAG="${GITHUB_REGISTRY_PULL_IMAGE_TAG}" +HOST_USER_ID="${HOST_USER_ID}" +HOST_GROUP_ID="${HOST_GROUP_ID}" +HOST_OS="${HOST_OS}" +HOST_HOME="${HOST_HOME}" +INIT_SCRIPT_FILE="${INIT_SCRIPT_FILE}" +INSTALL_AIRFLOW_VERSION="${INSTALL_AIRFLOW_VERSION}" +GENERATE_CONSTRAINTS_MODE="${GENERATE_CONSTRAINTS_MODE}" +INSTALL_PROVIDERS_FROM_SOURCES="${INSTALL_PROVIDERS_FROM_SOURCES}" +USE_AIRFLOW_VERSION="${USE_AIRFLOW_VERSION}" +USE_PACKAGES_FROM_DIST="${USE_PACKAGES_FROM_DIST}" +ISSUE_ID="${ISSUE_ID}" +LOAD_DEFAULT_CONNECTIONS="${LOAD_DEFAULT_CONNECTIONS}" +LOAD_EXAMPLES="${LOAD_EXAMPLES}" +MYSQL_VERSION="${MYSQL_VERSION}" +NUM_RUNS="${NUM_RUNS}" +PACKAGE_FORMAT="${PACKAGE_FORMAT}" +POSTGRES_VERSION="${POSTGRES_VERSION}" +PRINT_INFO_FROM_SCRIPTS="${PRINT_INFO_FROM_SCRIPTS}" +PYTHONDONTWRITEBYTECODE="${PYTHONDONTWRITEBYTECODE}" +PYTHON_MAJOR_MINOR_VERSION="${PYTHON_MAJOR_MINOR_VERSION}" +RUN_TESTS="${RUN_TESTS}" +RUN_INTEGRATION_TESTS="${RUN_INTEGRATION_TESTS}" +RUN_SYSTEM_TESTS="${RUN_SYSTEM_TESTS}" +START_AIRFLOW="${START_AIRFLOW}" +TEST_TYPE="${TEST_TYPE}" +UPGRADE_TO_NEWER_DEPENDENCIES="${UPGRADE_TO_NEWER_DEPENDENCIES}" +VERBOSE="${VERBOSE}" +VERBOSE_COMMANDS="${VERBOSE_COMMANDS}" +VERSION_SUFFIX_FOR_PYPI="${VERSION_SUFFIX_FOR_PYPI}" +VERSION_SUFFIX_FOR_SVN="${VERSION_SUFFIX_FOR_SVN}" +WHEEL_VERSION="${WHEEL_VERSION}" diff --git a/scripts/ci/docker-compose/base.yml b/scripts/ci/docker-compose/base.yml index cefb4925961..c9fed6afca1 100644 --- a/scripts/ci/docker-compose/base.yml +++ b/scripts/ci/docker-compose/base.yml @@ -27,7 +27,7 @@ services: - KUBECONFIG=/files/.kube/config - HOST_HOME=${HOME} env_file: - - _docker.env + - _docker_compose.env volumes: # Pass docker to inside of the container so that Kind and Moto tests can use it. - /var/run/docker.sock:/var/run/docker.sock diff --git a/scripts/ci/testing/ci_run_single_airflow_test_in_docker.sh b/scripts/ci/testing/ci_run_single_airflow_test_in_docker.sh index a88d061b89f..f2af0b92c3c 100755 --- a/scripts/ci/testing/ci_run_single_airflow_test_in_docker.sh +++ b/scripts/ci/testing/ci_run_single_airflow_test_in_docker.sh @@ -112,7 +112,7 @@ function run_airflow_testing_in_docker() { fi echo "Making sure docker-compose is down and remnants removed" echo - docker-compose --log-level INFO -f "${SCRIPTS_CI_DIR}/docker-compose/base.yml" \ + docker-compose -f "${SCRIPTS_CI_DIR}/docker-compose/base.yml" \ --project-name "airflow-${TEST_TYPE}-${BACKEND}" \ down --remove-orphans \ --volumes --timeout 10