Skip to content

Commit

Permalink
backout changes to acquire-build-image
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoh committed Jan 31, 2023
1 parent 396a43f commit badeb7c
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions tools/ci-build/acquire-build-image
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@ 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 @@ -100,18 +93,19 @@ class Shell:
print(stderr)
print("-------------------")


not_found_messages = ["not found: manifest unknown"]
throttle_messages = ["toomanyrequests: Rate exceeded", "toomanyrequests: Data limit exceeded"]
not_found_message = "not found: manifest unknown"
throttle_message = "toomanyrequests: Rate exceeded"
retryable_messages = ["net/http: TLS handshake timeout"]
if status == 0:
return DockerPullResult.SUCCESS
elif output_contains_any(stdout, stderr, throttle_messages):
elif throttle_message in stdout or throttle_message in stderr:
return DockerPullResult.ERROR_THROTTLED
elif output_contains_any(stdout, stderr, not_found_messages):
elif not_found_message in stdout or not_found_message in stderr:
return DockerPullResult.NOT_FOUND
elif output_contains_any(stdout, stderr, retryable_messages):
return DockerPullResult.RETRYABLE_ERROR
else:
for message in retryable_messages:
if message in stdout or message in stderr:
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 Expand Up @@ -191,17 +185,16 @@ def acquire_build_image(context=Context.default(), shell=Shell()):
announce("Building a new image locally.")
shell.docker_build_base_image(context.image_tag, context.tools_path)

if context.github_actions:
announce("Saving base image for use in later jobs...")
shell.docker_save(
LOCAL_BASE_IMAGE_NAME,
context.image_tag,
context.start_path + "/smithy-rs-base-image"
)
else:
announce("Successfully pulled remote image!")
shell.docker_tag(REMOTE_BASE_IMAGE_NAME, context.image_tag, LOCAL_BASE_IMAGE_NAME, context.image_tag)

if context.github_actions:
announce("Saving base image for use in later jobs...")
shell.docker_save(
LOCAL_BASE_IMAGE_NAME,
context.image_tag,
context.start_path + "/smithy-rs-base-image"
)
else:
announce("Base image found locally! No retrieval or rebuild necessary.")

Expand Down

0 comments on commit badeb7c

Please sign in to comment.