Skip to content

Commit

Permalink
Add Data limit exceeded to build image throttle messages (#2260)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdisanti authored Jan 30, 2023
1 parent 861d1d8 commit c04c6ab
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tools/ci-build/acquire-build-image
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`
Expand Down

0 comments on commit c04c6ab

Please sign in to comment.