1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
10 with open("config.json") as f:
13 scrub_collections = set(config["scrub_collections"])
15 for cluster_id in config["arvados_cluster_ids"]:
17 for scrub_image in config["scrub_images"]:
18 sp = scrub_image.split(":")
20 image_tag = sp[1] if len(sp) > 1 else "latest"
21 images.append('{}:{}'.format(image_name, image_tag))
23 search_links = api.links().list(
24 filters=[['link_class', '=', 'docker_image_repo+tag'],
25 ['name', 'in', images]],
26 cluster_id=cluster_id).execute()
28 head_uuids = [lk["head_uuid"] for lk in search_links["items"]]
29 cols = api.collections().list(filters=[["uuid", "in", head_uuids]],
30 cluster_id=cluster_id).execute()
31 for c in cols["items"]:
32 scrub_collections.add(c["portable_data_hash"])
33 for lk in search_links["items"]:
34 api.links().delete(uuid=lk["uuid"]).execute()
36 for cluster_id in config["arvados_cluster_ids"]:
37 matches = api.collections().list(filters=[["portable_data_hash", "in", list(scrub_collections)]],
38 select=["uuid", "portable_data_hash"], cluster_id=cluster_id).execute()
39 for m in matches["items"]:
40 api.collections().delete(uuid=m["uuid"]).execute()
41 print("Scrubbed %s (%s)" % (m["uuid"], m["portable_data_hash"]))