-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
koji scripts: improve garbage collection
* Untag builds whose only tag is built-by-xcp-ng (script untag_lone_builds.py) * Run koji-gc --delete to delete builds marked for deletion (trashcan tag) previously. * Run koji-gc --trash to mark untagged builds for deletion (trashcan tag). Signed-off-by: Samuel Verschelde <[email protected]>
- Loading branch information
Showing
2 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env python | ||
from __future__ import print_function | ||
|
||
import koji | ||
|
||
config = koji.read_config("koji") | ||
s = koji.ClientSession('https://kojihub.xcp-ng.org', config) | ||
s.ssl_login(config['cert'], None, config['serverca']) | ||
|
||
# We look for builds tagged only with built-by-xcp-ng, and no other tag | ||
# These are builds that we don't need in our history and that we could | ||
# delete to recover some disk space. | ||
# To do so, we just untag them, so that koji-gc later marks them for deletion | ||
# if all conditions for this are met. | ||
tag = 'built-by-xcp-ng' | ||
tagged = s.listTagged(tag) | ||
result = [] | ||
with s.multicall() as m: | ||
result = [m.listTags(binfo) for binfo in tagged] | ||
loners = [] | ||
for binfo, tinfos in zip(tagged, result): | ||
tags = [tinfo['name'] for tinfo in tinfos.result] | ||
if len(tags) == 1: | ||
loners.append((binfo['id'], binfo['nvr'])) | ||
|
||
print("The following packages built by XCP-ng don't belong to any tag other than %s" % tag) | ||
print("and will be removed from it so that they can be garbage-collected later.") | ||
for id, nvr in loners: | ||
print("Untagging build {} ({}) from {}.".format(id, nvr, tag)) | ||
s.untagBuild(tag, id) |