koji-gc: Implement hastag policy for koji-gc
Fixes: https://pagure.io/koji/issue/2813 Signed-off-by: Igor Raits <igor.raits@gmail.com>
This commit is contained in:
parent
880826b99e
commit
e0d770d10a
2 changed files with 14 additions and 0 deletions
|
|
@ -168,6 +168,7 @@ comments.
|
||||||
# stuff to protect
|
# stuff to protect
|
||||||
# note that tags with master lock engaged are already protected
|
# note that tags with master lock engaged are already protected
|
||||||
tag *-updates :: keep
|
tag *-updates :: keep
|
||||||
|
hastag no-gc :: skip
|
||||||
age < 1 day :: skip
|
age < 1 day :: skip
|
||||||
sig fedora-gold :: skip
|
sig fedora-gold :: skip
|
||||||
sig fedora-test && age < 12 weeks :: keep
|
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)
|
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):
|
def read_policies(fn=None):
|
||||||
"""Read tag gc policies from file
|
"""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['keys'] = LazyValue(get_build_sigs, (entry['build_id'],), {'cache': True})
|
||||||
data['volname'] = LazyValue(lambda x: session.getBuild(x).get('volume_name'),
|
data['volname'] = LazyValue(lambda x: session.getBuild(x).get('volume_name'),
|
||||||
(entry['build_id'],), cache=True)
|
(entry['build_id'],), cache=True)
|
||||||
|
data['tags'] = LazyValue(session.listTags, (entry['build_id'],), cache=True)
|
||||||
build_ids[nvr] = entry['build_id']
|
build_ids[nvr] = entry['build_id']
|
||||||
action = policies.apply(data)
|
action = policies.apply(data)
|
||||||
if action is None:
|
if action is None:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue