osclib/request_splitter: provide stageable option and make default True.

Without this, the relative rarer types of requests seen in projects with
staging and handled by list command will be included in staging proposal.
However, since they are not stageable the select operation will fail. This
change ensures that a filter is always present when stageable is True to
exclude non-stableable requests. The list command sets stageable to false
in order to list out the non-stageable requests of interest.

This was not observed in openSUSE since the main non-stageable request was
change_devel and that was exluded in StrategyNone. That filter could be
replaced with the stageable filter, but having an always on filter seems to
make more sense since generally operating in one of two modes.
This commit is contained in:
Jimmy Berry 2018-10-31 16:24:16 -05:00
parent 0d9cde5a90
commit 52eb890d76
2 changed files with 7 additions and 3 deletions

View File

@ -29,7 +29,6 @@ class ListCommand:
if not len(requests): return
splitter = RequestSplitter(self.api, requests, in_ring=True)
splitter.filter_add('./action[@type="submit" or @type="delete"]')
splitter.group_by('./action/target/@devel_project')
splitter.split()
@ -68,6 +67,7 @@ class ListCommand:
print 'Not in a ring:', ' '.join(sorted(non_ring_packages))
# Print requests not handled by staging process to highlight them.
splitter.stageable = False
for request_type in ('change_devel', 'set_bugowner'):
splitter.reset()
splitter.filter_add('./action[@type="{}"]'.format(request_type))

View File

@ -9,10 +9,11 @@ from osclib.core import request_age
import re
class RequestSplitter(object):
def __init__(self, api, requests, in_ring):
def __init__(self, api, requests, in_ring, stageable=True):
self.api = api
self.requests = requests
self.in_ring = in_ring
self.stageable = stageable
self.config = conf.config[self.api.project]
# 55 minutes to avoid two staging bot loops of 30 minutes
@ -38,6 +39,10 @@ class RequestSplitter(object):
self.other = []
self.grouped = {}
if self.stageable:
# Require requests to be stageable (submit or delete package).
self.filter_add('./action[@type="submit" or (@type="delete" and ./target[@package])]')
def strategy_set(self, name, **kwargs):
self.reset()
@ -393,7 +398,6 @@ class Strategy(object):
class StrategyNone(Strategy):
def apply(self, splitter):
splitter.filter_add('./action[not(@type="add_role" or @type="change_devel")]')
# All other strategies that inherit this are not restricted by age as
# the age restriction is used to allow other strategies to be observed.
if type(self) is StrategyNone: