Commit bffebc14 authored by Mitar's avatar Mitar

Cleaning Docker images.

parent cfbf5de1
Pipeline #97995797 failed with stages
in 38 minutes and 16 seconds
......@@ -474,6 +474,7 @@ def validate_installation(primitive_names, interface_version, installation, anno
existing_python_lib_dir = None
updated_python_lib_dir = None
already_updated_apt = False
pulled_docker_images = []
try:
print(">>> Existing Python packages installed:", flush=True)
existing_packages = set(docker_exec(docker_container, ['pip3', '--disable-pip-version-check', 'freeze']).splitlines())
......@@ -550,9 +551,10 @@ def validate_installation(primitive_names, interface_version, installation, anno
return
elif installation_entry['type'] == 'DOCKER':
print(">>> Validating Docker image '{image_name}@{image_digest}'.".format(image_name=installation_entry['image_name'], image_digest=installation_entry['image_digest']), flush=True)
docker_image_name = '{image_name}@{image_digest}'.format(image_name=installation_entry['image_name'], image_digest=installation_entry['image_digest'])
print(">>> Validating Docker image '{docker_image_name}'.".format(docker_image_name=docker_image_name), flush=True)
previous_chunk = None
for chunk in docker_client.api.pull('{image_name}@{image_digest}'.format(image_name=installation_entry['image_name'], image_digest=installation_entry['image_digest']), stream=True, decode=True):
for chunk in docker_client.api.pull(docker_image_name, stream=True, decode=True):
if 'status' in chunk:
if previous_chunk == chunk['status']:
sys.stdout.write('.')
......@@ -562,6 +564,8 @@ def validate_installation(primitive_names, interface_version, installation, anno
previous_chunk = chunk['status']
pulled_docker_images.append(docker_image_name)
elif installation_entry['type'] == 'UBUNTU':
print(">>> Installing Ubuntu package '{package}'.".format(package=installation_entry['package']), flush=True)
if not already_updated_apt:
......@@ -899,6 +903,11 @@ def validate_installation(primitive_names, interface_version, installation, anno
if updated_python_lib_dir is not None:
updated_python_lib_dir.cleanup()
if arguments.clean:
for docker_image_name in pulled_docker_images:
print(">>> Removing Docker image '{docker_image_name}'.".format(docker_image_name=docker_image_name), flush=True)
docker_client.images.remove(docker_image_name, force=True)
main_repository = private_git_uri_access(MAIN_REPOSITORY)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment