Skip to content

Commit 68bd876

Browse files
author
Alex Langenfeld
authored
[TEST_PYTHON_VERSIONS=test-all] only set docker api version in bk (#33067)
## ancient version problems limited to CI ## How I Tested These Changes bk, and run pytest locally where docker compose is used
1 parent de5e27c commit 68bd876

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

python_modules/dagster-test/dagster_test/fixtures/docker_compose.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def docker_compose_cm(
4747

4848
def dump_docker_compose_logs(context, docker_compose_yml):
4949
env = os.environ.copy()
50-
env["DOCKER_API_VERSION"] = "1.41"
50+
if env.get("BUILDKITE"):
51+
env["DOCKER_API_VERSION"] = "1.41"
5152
if context:
5253
compose_command = ["docker", "--context", context, "compose"]
5354
else:
@@ -91,7 +92,8 @@ def docker_compose(docker_compose_cm):
9192

9293
def docker_compose_up(docker_compose_yml, context, service, env_file, no_build: bool = False):
9394
docker_env = os.environ.copy()
94-
docker_env["DOCKER_API_VERSION"] = "1.41"
95+
if docker_env.get("BUILDKITE"):
96+
docker_env["DOCKER_API_VERSION"] = "1.41"
9597
if context:
9698
compose_command = ["docker", "--context", context, "compose"]
9799
else:
@@ -118,7 +120,8 @@ def docker_compose_up(docker_compose_yml, context, service, env_file, no_build:
118120

119121
def docker_compose_down(docker_compose_yml, context, service, env_file):
120122
docker_env = os.environ.copy()
121-
docker_env["DOCKER_API_VERSION"] = "1.41"
123+
if docker_env.get("BUILDKITE"):
124+
docker_env["DOCKER_API_VERSION"] = "1.41"
122125
if context:
123126
compose_command = ["docker", "--context", context, "compose"]
124127
else:
@@ -145,7 +148,8 @@ def docker_compose_down(docker_compose_yml, context, service, env_file):
145148
def list_containers():
146149
# TODO: Handle default container names: {project_name}_service_{task_number}
147150
env = os.environ.copy()
148-
env["DOCKER_API_VERSION"] = "1.41"
151+
if env.get("BUILDKITE"):
152+
env["DOCKER_API_VERSION"] = "1.41"
149153
return (
150154
subprocess.check_output(["docker", "ps", "--format", "{{.Names}}"], env=env)
151155
.decode()
@@ -156,7 +160,8 @@ def list_containers():
156160
def current_container():
157161
container_id = subprocess.check_output(["cat", "/etc/hostname"]).strip().decode()
158162
env = os.environ.copy()
159-
env["DOCKER_API_VERSION"] = "1.41"
163+
if env.get("BUILDKITE"):
164+
env["DOCKER_API_VERSION"] = "1.41"
160165
container = (
161166
subprocess.check_output(
162167
["docker", "ps", "--filter", f"id={container_id}", "--format", "{{.Names}}"], env=env
@@ -171,7 +176,8 @@ def connect_container_to_network(container, network):
171176
# subprocess.run instead of subprocess.check_call so we don't fail when
172177
# trying to connect a container to a network that it's already connected to
173178
env = os.environ.copy()
174-
env["DOCKER_API_VERSION"] = "1.41"
179+
if env.get("BUILDKITE"):
180+
env["DOCKER_API_VERSION"] = "1.41"
175181
try:
176182
subprocess.check_call(["docker", "network", "connect", network, container], env=env)
177183
logging.info(f"Connected {container} to network {network}.")
@@ -181,7 +187,8 @@ def connect_container_to_network(container, network):
181187

182188
def disconnect_container_from_network(container, network):
183189
env = os.environ.copy()
184-
env["DOCKER_API_VERSION"] = "1.41"
190+
if env.get("BUILDKITE"):
191+
env["DOCKER_API_VERSION"] = "1.41"
185192
try:
186193
subprocess.check_call(["docker", "network", "disconnect", network, container], env=env)
187194
logging.info(f"Disconnected {container} from network {network}.")
@@ -191,7 +198,8 @@ def disconnect_container_from_network(container, network):
191198

192199
def hostnames(network):
193200
env = os.environ.copy()
194-
env["DOCKER_API_VERSION"] = "1.41"
201+
if env.get("BUILDKITE"):
202+
env["DOCKER_API_VERSION"] = "1.41"
195203
hostnames = {}
196204
for container in list_containers():
197205
output = subprocess.check_output(["docker", "inspect", container], env=env)

0 commit comments

Comments
 (0)