Skip to content

Commit f9b152a

Browse files
fix healthcheck bug (#247)
1 parent 0bb0075 commit f9b152a

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

devservices/commands/up.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def _up(
225225
for cmd in up_commands:
226226
try:
227227
container_names = get_container_names_for_project(
228-
cmd.project_name, cmd.config_path
228+
cmd.project_name, cmd.config_path, cmd.services
229229
)
230230
containers_to_check.extend(container_names)
231231
except DockerComposeError as dce:

devservices/utils/docker_compose.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def install_docker_compose() -> None:
9595

9696

9797
def get_container_names_for_project(
98-
project_name: str, config_path: str
98+
project_name: str, config_path: str, services: list[str]
9999
) -> list[ContainerNames]:
100100
try:
101101
output = subprocess.check_output(
@@ -107,6 +107,9 @@ def get_container_names_for_project(
107107
"-f",
108108
config_path,
109109
"ps",
110+
]
111+
+ sorted(services)
112+
+ [
110113
"--format",
111114
'{"name":"{{.Names}}", "short_name":"{{.Service}}"}',
112115
],

tests/utils/test_docker_compose.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,9 @@ def test_get_all_commands_to_run_complex_shared_dependency(
775775
@mock.patch("devservices.utils.docker_compose.subprocess.check_output")
776776
def test_get_container_names_for_project_success(_mock_check_output: mock.Mock) -> None:
777777
_mock_check_output.return_value = '{"name": "devservices-container1", "short_name": "container1"}\n{"name": "devservices-container2", "short_name": "container2"}'
778-
assert get_container_names_for_project("project", "config_path") == [
778+
assert get_container_names_for_project(
779+
"project", "config_path", ["container1", "container2"]
780+
) == [
779781
ContainerNames(name="devservices-container1", short_name="container1"),
780782
ContainerNames(name="devservices-container2", short_name="container2"),
781783
]
@@ -787,5 +789,7 @@ def test_get_container_names_for_project_error(_mock_check_output: mock.Mock) ->
787789
returncode=1, cmd="docker compose ps --format", stderr="command failed"
788790
)
789791
with pytest.raises(DockerComposeError) as e:
790-
get_container_names_for_project("project", "config_path")
792+
get_container_names_for_project(
793+
"project", "config_path", ["container1", "container2"]
794+
)
791795
assert e.value.stderr == "command failed"

0 commit comments

Comments
 (0)