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