Skip to content

Commit

Permalink
Optimise production image building during k8s tests on CI (#10476)
Browse files Browse the repository at this point in the history
We do not have to rebuild PROD images now because we changed
the strategy of preparing the image for k8s tests instead of
embedding dags during build with EMBEDDED_DAGS build arg we
are now extending the image with FROM: clause and add dags
on top of the PROD base image. We've been rebuilding the
image twice during each k8s run - once in Prepare PROD image
and once in "Deploy airflow to cluster" both are not needed
and both lasted ~ 2m 30s, so we should save around 5m for every
K8S jobi (~30% as the while K8S test job is around 15m).
  • Loading branch information
potiuk committed Aug 22, 2020
1 parent c635804 commit 93ba98c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,9 @@ jobs:
run: ./scripts/ci/images/ci_prepare_prod_image_on_ci.sh
- name: "Deploy airflow to cluster"
run: ./scripts/ci/kubernetes/ci_deploy_app_to_kubernetes.sh
env:
# We have the right image pulled already by the previous step
SKIP_BUILDING_PROD_IMAGE: "true"
- name: "Cache virtualenv for kubernetes testing"
uses: actions/cache@v2
env:
Expand Down
2 changes: 2 additions & 0 deletions breeze
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ function parse_arguments() {
echo "Skips checking image for rebuilds"
echo
export CHECK_IMAGE_FOR_REBUILD="false"
export SKIP_BUILDING_PROD_IMAGE="true"
shift ;;
-L|--build-cache-local)
echo "Use local cache to build images"
Expand Down Expand Up @@ -816,6 +817,7 @@ function parse_arguments() {
export GITHUB_REGISTRY_PULL_IMAGE_TAG="${2}"
export GITHUB_REGISTRY_PUSH_IMAGE_TAG="${2}"
export CHECK_IMAGE_FOR_REBUILD="false"
export SKIP_BUILDING_PROD_IMAGE="true"
export MOUNT_LOCAL_SOURCES="false"
export SKIP_CHECK_REMOTE_IMAGE="true"
shift 2;;
Expand Down
3 changes: 2 additions & 1 deletion scripts/ci/images/ci_prepare_prod_image_on_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ function build_prod_images_on_ci() {

wait_for_image_tag "${GITHUB_REGISTRY_AIRFLOW_PROD_BUILD_IMAGE}" \
":${GITHUB_REGISTRY_PULL_IMAGE_TAG}" "${AIRFLOW_PROD_BUILD_IMAGE}"
else
build_prod_images
fi

build_prod_images

# Disable force pulling forced above this is needed for the subsequent scripts so that
# They do not try to pull/build images again
Expand Down
9 changes: 9 additions & 0 deletions scripts/ci/libraries/_build_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,15 @@ function prepare_prod_build() {
# selected by Breeze flags or environment variables.
function build_prod_images() {
print_build_info

if [[ ${SKIP_BUILDING_PROD_IMAGE:="false"} == "true" ]]; then
print_info
print_info "Skip building production image. Assume the one we have is good!"
print_info
return
fi


pull_prod_images_if_needed

if [[ "${DOCKER_CACHE}" == "disabled" ]]; then
Expand Down

0 comments on commit 93ba98c

Please sign in to comment.