Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions scripts/update_container_hashes/container_hashes_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_container_info(
content = f.read()

try:
os.remove(synapse_tmp_file)
os.remove(synapse_tmp_file.path)
except OSError:
print(
f"Failed to delete local Synapse file {synapse_tmp_file.path}. "
Expand All @@ -45,7 +45,7 @@ def get_container_info(
else:
content = req_session.get(download_link).content

content_hash = hashlib.sha256(content).hexdigest()
content_hash = hashlib.sha256(content.encode("utf-8")).hexdigest()
hashes_matched = content_hash == expected_hash
if not hashes_matched:
print(
Expand Down Expand Up @@ -74,7 +74,18 @@ def get_docker_hash(
return new_hash
except APIError:
if current_try > MAX_TRIES:
raise
try:
image_info = docker_client.images.pull(docker_info_dict["image"])
new_hash = image_info.id
docker_client.images.remove(image=image_info.id, force=True)
return new_hash
except docker.errors.ImageNotFound:
print(
f"Image {docker_info_dict['image']} (Container {container_id}) no longer exists."
)
return None
except APIError:
raise
print(
f"An error happened when attempting to get registry data from "
f"Container {container_id}. Will try again {MAX_TRIES - current_try} times..."
Expand Down Expand Up @@ -143,6 +154,7 @@ def get_container_hashes(
)
else:
parameters_config = {}
parameters_hash_matched = None

new_hash = get_docker_hash(
docker_client=docker_client,
Expand Down
Loading