Skip to content

Commit

Permalink
Do not add local airflow sources in CI when building k8s image (apach…
Browse files Browse the repository at this point in the history
…e#39043)

Follow up after apache#39035 where local airflow sources have been
removed from PROD image built in CI. The k8s image for tests also
added the sources when preparing the modified image. This is now
avoided - the --no-copy-local-sources is used in CI to avoid it.
  • Loading branch information
potiuk authored and RodrigoGanancia committed May 10, 2024
1 parent 168264c commit c67d2db
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/k8s-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
k8s-env-${{ steps.breeze.outputs.host-python-version }}-\
${{ hashFiles('scripts/ci/kubernetes/k8s_requirements.txt','pyproject.toml') }}"
- name: Run complete K8S tests ${{ inputs.kubernetes-combos-list-as-string }}
run: breeze k8s run-complete-tests --run-in-parallel --upgrade
run: breeze k8s run-complete-tests --run-in-parallel --upgrade --no-copy-local-sources
env:
PYTHON_VERSIONS: ${{ inputs.python-versions-list-as-string }}
KUBERNETES_VERSIONS: ${{ inputs.kubernetes-versions-list-as-string }}
Expand Down
62 changes: 35 additions & 27 deletions dev/breeze/doc/images/output_k8s_build-k8s-image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion dev/breeze/doc/images/output_k8s_build-k8s-image.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1739395599162dcc262156a26dd9b2e7
f9669ae229dfd2954ae7bf6f66bb92bf
86 changes: 47 additions & 39 deletions dev/breeze/doc/images/output_k8s_run-complete-tests.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion dev/breeze/doc/images/output_k8s_run-complete-tests.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
271d2d80bf3312137ba0f412900a82b8
12252b79a0cfefe84397aeacb4beb1e2
25 changes: 24 additions & 1 deletion dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ def kubernetes_group():
pass


option_copy_local_sources = click.option(
"--copy-local-sources/--no-copy-local-sources",
help="Copy local sources to the image.",
default=True,
show_default=True,
envvar="COPY_LOCAL_SOURCES",
)
option_executor = click.option(
"--executor",
help="Executor to use for a kubernetes cluster.",
Expand Down Expand Up @@ -557,6 +564,7 @@ def _rebuild_k8s_image(
python: str,
image_tag: str,
rebuild_base_image: bool,
copy_local_sources: bool,
use_uv: bool,
output: Output | None,
) -> tuple[int, str]:
Expand Down Expand Up @@ -587,10 +595,15 @@ def _rebuild_k8s_image(
f"[info]Building the K8S image for Python {python} using "
f"airflow base image: {params.airflow_image_name_with_tag}\n"
)
if copy_local_sources:
extra_copy_command = "COPY . /opt/airflow/"
else:
extra_copy_command = ""
docker_image_for_kubernetes_tests = f"""
FROM {params.airflow_image_name_with_tag}
COPY . /opt/airflow/
{extra_copy_command}
COPY airflow/example_dags/ /opt/airflow/dags/
COPY airflow/providers/cncf/kubernetes/kubernetes_executor_templates/ /opt/airflow/pod_templates/
Expand Down Expand Up @@ -636,6 +649,7 @@ def _upload_k8s_image(python: str, kubernetes_version: str, output: Output | Non
help="Build k8s-ready airflow image (optionally all images in parallel).",
)
@option_answer
@option_copy_local_sources
@option_debug_resources
@option_dry_run
@option_image_tag
Expand All @@ -649,6 +663,7 @@ def _upload_k8s_image(python: str, kubernetes_version: str, output: Output | Non
@option_use_uv
@option_verbose
def build_k8s_image(
copy_local_sources: bool,
debug_resources: bool,
image_tag: str,
include_success_outputs: bool,
Expand Down Expand Up @@ -680,6 +695,7 @@ def build_k8s_image(
"python": _python,
"image_tag": image_tag,
"rebuild_base_image": rebuild_base_image,
"copy local sources": copy_local_sources,
"use_uv": use_uv,
"output": outputs[index],
},
Expand All @@ -698,6 +714,7 @@ def build_k8s_image(
python=python,
image_tag=image_tag,
rebuild_base_image=rebuild_base_image,
copy_local_sources=copy_local_sources,
use_uv=use_uv,
output=None,
)
Expand Down Expand Up @@ -1515,6 +1532,7 @@ def _run_complete_tests(
executor: str,
image_tag: str,
rebuild_base_image: bool,
copy_local_sources: bool,
use_uv: bool,
upgrade: bool,
wait_time_in_seconds: int,
Expand All @@ -1532,6 +1550,7 @@ def _run_complete_tests(
image_tag=image_tag,
use_uv=use_uv,
rebuild_base_image=rebuild_base_image,
copy_local_sources=copy_local_sources,
)
if returncode != 0:
return returncode, message
Expand Down Expand Up @@ -1646,6 +1665,7 @@ def _run_complete_tests(
)
@option_debug_resources
@option_dry_run
@option_copy_local_sources
@option_executor
@option_force_recreate_cluster
@option_force_venv_setup
Expand All @@ -1666,6 +1686,7 @@ def _run_complete_tests(
@option_wait_time_in_seconds
@click.argument("test_args", nargs=-1, type=click.Path())
def run_complete_tests(
copy_local_sources: bool,
debug_resources: bool,
executor: str,
force_recreate_cluster: bool,
Expand Down Expand Up @@ -1728,6 +1749,7 @@ def run_complete_tests(
"executor": executor,
"image_tag": image_tag,
"rebuild_base_image": rebuild_base_image,
"copy_local_sources": copy_local_sources,
"use_uv": use_uv,
"upgrade": upgrade,
"wait_time_in_seconds": wait_time_in_seconds,
Expand Down Expand Up @@ -1755,6 +1777,7 @@ def run_complete_tests(
executor=executor,
image_tag=image_tag,
rebuild_base_image=rebuild_base_image,
copy_local_sources=copy_local_sources,
use_uv=use_uv,
upgrade=upgrade,
wait_time_in_seconds=wait_time_in_seconds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"--python",
"--image-tag",
"--rebuild-base-image",
"--copy-local-sources",
"--use-uv",
],
},
Expand Down Expand Up @@ -233,6 +234,7 @@
"options": [
"--image-tag",
"--rebuild-base-image",
"--copy-local-sources",
"--use-uv",
],
},
Expand Down

0 comments on commit c67d2db

Please sign in to comment.