From c04c6ab4d72d82594f2841ddd67296a6ae2b63ec Mon Sep 17 00:00:00 2001 From: John DiSanti Date: Mon, 30 Jan 2023 12:12:29 -0800 Subject: [PATCH] Add `Data limit exceeded` to build image throttle messages (#2260) --- tools/ci-build/acquire-build-image | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tools/ci-build/acquire-build-image b/tools/ci-build/acquire-build-image index 7c4bbd7a62..bcc82bcb3c 100755 --- a/tools/ci-build/acquire-build-image +++ b/tools/ci-build/acquire-build-image @@ -69,6 +69,13 @@ class Context: return Context(start_path, script_path, tools_path, user_id, image_tag, allow_local_build, github_actions) +def output_contains_any(stdout, stderr, messages): + for message in messages: + if message in stdout or message in stderr: + return True + return False + + # Mockable shell commands class Shell: # Returns the platform that this script is running on @@ -93,19 +100,17 @@ class Shell: print(stderr) print("-------------------") - not_found_message = "not found: manifest unknown" - throttle_message = "toomanyrequests: Rate exceeded" + not_found_messages = ["not found: manifest unknown"] + throttle_messages = ["toomanyrequests: Rate exceeded", "toomanyrequests: Data limit exceeded"] retryable_messages = ["net/http: TLS handshake timeout"] if status == 0: return DockerPullResult.SUCCESS - elif throttle_message in stdout or throttle_message in stderr: + elif output_contains_any(stdout, stderr, throttle_messages): return DockerPullResult.ERROR_THROTTLED - elif not_found_message in stdout or not_found_message in stderr: + elif output_contains_any(stdout, stderr, not_found_messages): return DockerPullResult.NOT_FOUND - else: - for message in retryable_messages: - if message in stdout or message in stderr: - return DockerPullResult.RETRYABLE_ERROR + elif output_contains_any(stdout, stderr, retryable_messages): + return DockerPullResult.RETRYABLE_ERROR return DockerPullResult.UNKNOWN_ERROR # Builds the base image with the Dockerfile in `path` and tags with with `image_tag`