You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/04/06 02:44:14 UTC

[GitHub] [airflow] potiuk opened a new pull request #15222: Run kubernetes tests in parallel

potiuk opened a new pull request #15222:
URL: https://github.com/apache/airflow/pull/15222


   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   


-- 
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:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on pull request #15222: Run kubernetes tests in parallel

Posted by GitBox <gi...@apache.org>.
potiuk commented on pull request #15222:
URL: https://github.com/apache/airflow/pull/15222#issuecomment-815117398


   Wooho!. Almost evyrything sped up 


-- 
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:
users@infra.apache.org



[GitHub] [airflow] mik-laj commented on a change in pull request #15222: Run kubernetes tests in parallel

Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #15222:
URL: https://github.com/apache/airflow/pull/15222#discussion_r607450356



##########
File path: scripts/ci/kubernetes/ci_setup_clusters_and_run_kubernetes_tests_in_parallel.sh
##########
@@ -0,0 +1,106 @@
+#!/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.
+set -euo pipefail
+
+# We cannot perform full initialization because it will be done later in the "single run" scripts
+# And some readonly variables are set there, therefore we only selectively reuse parallel lib needed
+LIBRARIES_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../libraries/" && pwd)
+# shellcheck source=scripts/ci/libraries/_all_libs.sh
+source "${LIBRARIES_DIR}/_all_libs.sh"
+export SEMAPHORE_NAME="kubernetes-tests"
+
+function get_maximum_parallel_k8s_jobs() {
+    docker_engine_resources::get_available_cpus_in_docker
+    if [[ ${RUNS_ON} != *"self-hosted"* ]]; then
+        echo
+        echo "${COLOR_YELLOW}This is a Github Public runner - for now we are forcing max parallel K8S tests jobs to 1 for those${COLOR_RESET}"
+        echo
+        export MAX_PARALLEL_K8S_JOBS="1"
+    else
+        if [[ ${MAX_PARALLEL_K8S_JOBS=} != "" ]]; then
+            echo
+            echo "${COLOR_YELLOW}Maximum parallel k8s jobs forced vi MAX_PARALLEL_K8S_JOBS = ${MAX_PARALLEL_K8S_JOBS}${COLOR_RESET}"
+            echo
+        else
+            MAX_PARALLEL_K8S_JOBS=${CPUS_AVAILABLE_FOR_DOCKER}
+            echo
+            echo "${COLOR_YELLOW}Maximum parallel k8s jobs set to number of CPUs available for Docker = ${MAX_PARALLEL_K8S_JOBS}${COLOR_RESET}"
+            echo
+        fi
+    fi
+    export MAX_PARALLEL_K8S_JOBS
+}
+
+# Launches parallel building of images. Redirects output to log set the right directories
+# $1 - test_specification
+# $2 - bash file to execute in parallel
+function run_kubernetes_test() {
+    local kubernetes_version=$1
+    local python_version=$2
+    local job="Cluster-${kubernetes_version}-python-${python_version}"
+
+    mkdir -p "${PARALLEL_MONITORED_DIR}/${SEMAPHORE_NAME}/${job}"
+    export JOB_LOG="${PARALLEL_MONITORED_DIR}/${SEMAPHORE_NAME}/${job}/stdout"
+    export PARALLEL_JOB_STATUS="${PARALLEL_MONITORED_DIR}/${SEMAPHORE_NAME}/${job}/status"
+    echo "Starting K8S tests for kubernetes version ${kubernetes_version}, python version: ${python_version}"
+    parallel --ungroup --bg --semaphore --semaphorename "${SEMAPHORE_NAME}" \
+        --jobs "${MAX_PARALLEL_K8S_JOBS}" \
+            "$(dirname "${BASH_SOURCE[0]}")/ci_setup_cluster_and_run_kubernetes_tests_single_job.sh" \
+                "${kubernetes_version}" "${python_version}" >"${JOB_LOG}" 2>&1
+}
+
+function run_k8s_tests_in_parallel() {
+    start_end::group_start "Monitoring k8s tests"
+    parallel::cleanup_runner
+    parallel::initialize_monitoring
+    parallel::monitor_progress
+
+    # In case there are more kubernetes versions than strings, we can reuse python versions so we add it twice here
+    local repeated_python_versions
+    # shellcheck disable=SC2206
+    repeated_python_versions=(${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING} ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING})
+    local index=0
+    for kubernetes_version in ${CURRENT_KUBERNETES_VERSIONS_AS_STRING}
+    do
+        index=$((index + 1))
+        python_version=${repeated_python_versions[${index}]}
+        FORWARDED_PORT_NUMBER=$((38080 + index))
+        export FORWARDED_PORT_NUMBER
+        API_SERVER_PORT=$((19090 + index))
+        export API_SERVER_PORT
+        run_kubernetes_test "${kubernetes_version}" "${python_version}" "${@}"
+    done
+    set +e
+    parallel --semaphore --semaphorename "${SEMAPHORE_NAME}" --wait
+    parallel::kill_monitor
+    set -e
+    start_end::group_end
+}
+
+initialization::set_output_color_variables
+
+parallel::make_sure_gnu_parallel_is_installed
+parallel::make_sure_python_versions_are_specified
+parallell::make_sure_kubernetes_versions_are_specified

Review comment:
       ```suggestion
   parallel::make_sure_kubernetes_versions_are_specified
   ```




-- 
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:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on pull request #15222: Run kubernetes tests in parallel

Posted by GitBox <gi...@apache.org>.
potiuk commented on pull request #15222:
URL: https://github.com/apache/airflow/pull/15222#issuecomment-813991787


   yet another improvement in paralell tests . And it nicely works in Public Runners as well: https://github.com/potiuk/airflow/runs/2274880512?check_suite_focus=true
   
   I am going to close/reopen this one with 'full-test-needed' flag to see the improvements.


-- 
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:
users@infra.apache.org



[GitHub] [airflow] github-actions[bot] commented on pull request #15222: Run kubernetes tests in parallel

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #15222:
URL: https://github.com/apache/airflow/pull/15222#issuecomment-814746832


   [The Workflow run](https://github.com/apache/airflow/actions/runs/725397119) is cancelling this PR. Building images for the PR has failed. Follow the workflow link to check the reason.


-- 
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:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on pull request #15222: Run kubernetes tests in parallel

Posted by GitBox <gi...@apache.org>.
potiuk commented on pull request #15222:
URL: https://github.com/apache/airflow/pull/15222#issuecomment-814519586


   @mik-laj @kaxil 


-- 
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:
users@infra.apache.org



[GitHub] [airflow] potiuk merged pull request #15222: Run kubernetes tests in parallel

Posted by GitBox <gi...@apache.org>.
potiuk merged pull request #15222:
URL: https://github.com/apache/airflow/pull/15222


   


-- 
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:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on pull request #15222: Run kubernetes tests in parallel

Posted by GitBox <gi...@apache.org>.
potiuk commented on pull request #15222:
URL: https://github.com/apache/airflow/pull/15222#issuecomment-814519467


   Nice ! Parallel K8S run 3xdifferent combinations of K8S version + Python in 17 minutes. Previoyusly just 1 of the K8S runs run in 14 minutes. REady to merge!


-- 
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:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on pull request #15222: Run kubernetes tests in parallel

Posted by GitBox <gi...@apache.org>.
potiuk commented on pull request #15222:
URL: https://github.com/apache/airflow/pull/15222#issuecomment-814519863


   Last Parallel improvement for a while I think (maybe I perallelize image builds but this is a bit more tricky)


-- 
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:
users@infra.apache.org



[GitHub] [airflow] potiuk closed pull request #15222: Run kubernetes tests in parallel

Posted by GitBox <gi...@apache.org>.
potiuk closed pull request #15222:
URL: https://github.com/apache/airflow/pull/15222


   


-- 
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:
users@infra.apache.org