Skip to content

Commit

Permalink
Mark image as refreshed after it's build (apache#45386)
Browse files Browse the repository at this point in the history
Somewhere in the last refactorings and ci cache we lost marking the
image as "refreshed" after it's build. Currently it does not matter
if you press "y" or "n" when you are asked for image rebuilding
next time you are asked again, but it should not happen if your
image is rebuilt successfully.

This PR restores "mark image as refreshed" after it's rebuild
and renames it to "mark_image_as_rebuilt"
  • Loading branch information
potiuk authored Jan 4, 2025
1 parent 103b3ab commit e27a5f5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions dev/breeze/src/airflow_breeze/commands/ci_image_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
)
from airflow_breeze.utils.github import download_artifact_from_pr, download_artifact_from_run_id
from airflow_breeze.utils.image import run_pull_image, run_pull_in_parallel
from airflow_breeze.utils.mark_image_as_refreshed import mark_image_as_refreshed
from airflow_breeze.utils.mark_image_as_refreshed import mark_image_as_rebuilt
from airflow_breeze.utils.md5_build_check import md5sum_check_if_build_is_needed
from airflow_breeze.utils.parallel import (
DockerBuildxProgressMatcher,
Expand Down Expand Up @@ -692,7 +692,7 @@ def load(
image_file.unlink()
if get_verbose():
run_command(["docker", "images", "-a"])
mark_image_as_refreshed(ci_image_params=build_ci_params)
mark_image_as_rebuilt(ci_image_params=build_ci_params)


@ci_image.command(
Expand Down Expand Up @@ -938,6 +938,8 @@ def run_build_ci_image(
get_console().print(
"[info]Run `breeze ci-image build --upgrade-to-newer-dependencies` to upgrade them.\n"
)
if build_command_result.returncode == 0:
mark_image_as_rebuilt(ci_image_params=ci_image_params)
return build_command_result.returncode, f"Image build: {param_description}"


Expand Down
4 changes: 2 additions & 2 deletions dev/breeze/src/airflow_breeze/utils/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from airflow_breeze.params.shell_params import ShellParams
from airflow_breeze.utils.ci_group import ci_group
from airflow_breeze.utils.console import Output, get_console
from airflow_breeze.utils.mark_image_as_refreshed import mark_image_as_refreshed
from airflow_breeze.utils.mark_image_as_refreshed import mark_image_as_rebuilt
from airflow_breeze.utils.parallel import (
DOCKER_PULL_PROGRESS_REGEXP,
GenericRegexpProgressMatcher,
Expand Down Expand Up @@ -149,7 +149,7 @@ def run_pull_image(
f"Image Python {image_params.python}",
)
if isinstance(image_params, BuildCiParams):
mark_image_as_refreshed(image_params)
mark_image_as_rebuilt(image_params)
return command_result.returncode, f"Image Python {image_params.python}"
if wait_for_image:
if get_verbose() or get_dry_run():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from airflow_breeze.params.build_ci_params import BuildCiParams


def mark_image_as_refreshed(ci_image_params: BuildCiParams):
def mark_image_as_rebuilt(ci_image_params: BuildCiParams):
ci_image_cache_dir = BUILD_CACHE_DIR / ci_image_params.airflow_branch
ci_image_cache_dir.mkdir(parents=True, exist_ok=True)
touch_cache_file(f"built_{ci_image_params.python}", root_dir=ci_image_cache_dir)
Expand Down

0 comments on commit e27a5f5

Please sign in to comment.