PR#2817: koji-gc: Implement hastag policy for koji-gc
Merges #2817 https://pagure.io/koji/pull-request/2817 Fixes: #2813 https://pagure.io/koji/issue/2813 RFE: koji-gc: hastag policy
This commit is contained in:
commit
28eb8a81e1
2 changed files with 14 additions and 0 deletions
|
|
@ -168,6 +168,7 @@ comments.
|
|||
# stuff to protect
|
||||
# note that tags with master lock engaged are already protected
|
||||
tag *-updates :: keep
|
||||
hastag no-gc :: skip
|
||||
age < 1 day :: skip
|
||||
sig fedora-gold :: skip
|
||||
sig fedora-test && age < 12 weeks :: keep
|
||||
|
|
|
|||
13
util/koji-gc
13
util/koji-gc
|
|
@ -776,6 +776,18 @@ class AgePruneTest(koji.policy.BaseSimpleTest):
|
|||
return self.func(time.time() - data['ts'], self.span)
|
||||
|
||||
|
||||
class HasTagPruneTest(koji.policy.BaseSimpleTest):
|
||||
name = 'hastag'
|
||||
|
||||
def run(self, data):
|
||||
patterns = self.str.split()[1:]
|
||||
for tag in data['tags']:
|
||||
for pattern in patterns:
|
||||
if fnmatch.fnmatch(tag['name'], pattern):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def read_policies(fn=None):
|
||||
"""Read tag gc policies from file
|
||||
|
||||
|
|
@ -907,6 +919,7 @@ def handle_prune():
|
|||
data['keys'] = LazyValue(get_build_sigs, (entry['build_id'],), {'cache': True})
|
||||
data['volname'] = LazyValue(lambda x: session.getBuild(x).get('volume_name'),
|
||||
(entry['build_id'],), cache=True)
|
||||
data['tags'] = LazyValue(session.listTags, (entry['build_id'],), cache=True)
|
||||
build_ids[nvr] = entry['build_id']
|
||||
action = policies.apply(data)
|
||||
if action is None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue