Skip to content

Commit 999aad3

Browse files
authored
Fix docker version for Rancher Desktop (#44915)
1 parent 53ba335 commit 999aad3

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

dev/breeze/src/airflow_breeze/utils/docker_command_utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ def check_docker_version(quiet: bool = False):
205205
dry_run_override=False,
206206
)
207207
if docker_version_result.returncode == 0:
208-
docker_version = docker_version_result.stdout.strip()
208+
regex = re.compile(r"^(" + version.VERSION_PATTERN + r").*$", re.VERBOSE | re.IGNORECASE)
209+
docker_version = re.sub(regex, r"\1", docker_version_result.stdout.strip())
209210
if docker_version == "":
210211
get_console().print(
211212
f"""

dev/breeze/tests/test_docker_command_utils.py

+22
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,28 @@ def test_check_docker_version_higher(mock_get_console, mock_run_command, mock_ch
127127
mock_get_console.return_value.print.assert_called_with("[success]Good version of Docker: 24.0.0.[/]")
128128

129129

130+
@mock.patch("airflow_breeze.utils.docker_command_utils.check_docker_permission_denied")
131+
@mock.patch("airflow_breeze.utils.docker_command_utils.run_command")
132+
@mock.patch("airflow_breeze.utils.docker_command_utils.get_console")
133+
def test_check_docker_version_higher_rancher_desktop(
134+
mock_get_console, mock_run_command, mock_check_docker_permission_denied
135+
):
136+
mock_check_docker_permission_denied.return_value = False
137+
mock_run_command.return_value.returncode = 0
138+
mock_run_command.return_value.stdout = "24.0.0-rd"
139+
check_docker_version()
140+
mock_check_docker_permission_denied.assert_called()
141+
mock_run_command.assert_called_with(
142+
["docker", "version", "--format", "{{.Client.Version}}"],
143+
no_output_dump_on_exception=True,
144+
capture_output=True,
145+
text=True,
146+
check=False,
147+
dry_run_override=False,
148+
)
149+
mock_get_console.return_value.print.assert_called_with("[success]Good version of Docker: 24.0.0-r.[/]")
150+
151+
130152
@mock.patch("airflow_breeze.utils.docker_command_utils.run_command")
131153
@mock.patch("airflow_breeze.utils.docker_command_utils.get_console")
132154
def test_check_docker_compose_version_unknown(mock_get_console, mock_run_command):

0 commit comments

Comments
 (0)