Skip to content

Commit e3e0822

Browse files
authored
Add an env var that forces mzbuild to wait for an image to become available (MaterializeInc#3393)
We've had several load tests fail because they tried to use the most recent image, and it just happened to not be ready yet.
1 parent 803fbd6 commit e3e0822

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

misc/python/materialize/mzbuild.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import stat
4646
import subprocess
4747
import sys
48+
import time
4849

4950
import yaml
5051

@@ -451,11 +452,15 @@ def acquire(self) -> AcquiredFrom:
451452
acquired_from: How the image was acquired.
452453
"""
453454
if self.image.publish:
454-
try:
455-
spawn.runv(["docker", "pull", self.spec()])
456-
return AcquiredFrom.REGISTRY
457-
except subprocess.CalledProcessError:
458-
pass
455+
while True:
456+
try:
457+
spawn.runv(["docker", "pull", self.spec()])
458+
return AcquiredFrom.REGISTRY
459+
except subprocess.CalledProcessError:
460+
if not ui.env_is_truthy("MZBUILD_WAIT_FOR_IMAGE"):
461+
break
462+
print(f"waiting for mzimage to become available", file=sys.stderr)
463+
time.sleep(10)
459464
self.build()
460465
return AcquiredFrom.LOCAL_BUILD
461466

misc/python/materialize/ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def shell_quote(args: Iterable[Any]) -> str:
107107

108108

109109
def env_is_truthy(env_var: str) -> bool:
110-
"""Return true if `env_var` is set and is not one of: 0, n, no"""
110+
"""Return true if `env_var` is set and is not one of: 0, '', no"""
111111
env = os.getenv(env_var)
112112
if env is not None:
113113
return env not in ("", "0", "no")

0 commit comments

Comments
 (0)