Merge pull request #408 from aplanas/master
Some refactoring and a (maybe) better OBS's error detection
This commit is contained in:
commit
28e3183767
@ -26,6 +26,7 @@ from osc import oscerr
|
||||
_plugin_dir = os.path.expanduser('~/.osc-plugins')
|
||||
sys.path.append(_plugin_dir)
|
||||
from osclib.accept_command import AcceptCommand
|
||||
from osclib.adi_command import AdiCommand
|
||||
from osclib.check_command import CheckCommand
|
||||
from osclib.cleanup_rings import CleanupRings
|
||||
from osclib.conf import Config
|
||||
@ -35,7 +36,6 @@ from osclib.obslock import OBSLock
|
||||
from osclib.select_command import SelectCommand
|
||||
from osclib.stagingapi import StagingAPI
|
||||
from osclib.unselect_command import UnselectCommand
|
||||
from osclib.adi_command import AdiCommand
|
||||
|
||||
OSC_STAGING_VERSION = '0.0.1'
|
||||
|
||||
@ -168,7 +168,7 @@ def do_staging(self, subcmd, opts, *args):
|
||||
api.mark_additional_packages(tprj, [opts.add])
|
||||
else:
|
||||
SelectCommand(api, tprj).perform(args[2:], opts.move,
|
||||
opts.from_, opts.no_freeze)
|
||||
opts.from_, opts.no_freeze)
|
||||
elif cmd == 'cleanup_rings':
|
||||
CleanupRings(api).perform()
|
||||
elif cmd == 'list':
|
||||
|
@ -296,16 +296,13 @@ class CheckRepo(object):
|
||||
def _last_build_success(self, src_project, tgt_project, src_package, rev):
|
||||
"""Return the last build success XML document from OBS."""
|
||||
xml = ''
|
||||
try:
|
||||
url = makeurl(self.apiurl,
|
||||
('build', src_project,
|
||||
'_result?lastsuccess&package=%s&pathproject=%s&srcmd5=%s' % (
|
||||
quote_plus(src_package),
|
||||
quote_plus(tgt_project),
|
||||
rev)))
|
||||
xml = http_GET(url).read()
|
||||
except urllib2.HTTPError, e:
|
||||
print('ERROR in URL %s [%s]' % (url, e))
|
||||
url = makeurl(self.apiurl,
|
||||
('build', src_project,
|
||||
'_result?lastsuccess&package=%s&pathproject=%s&srcmd5=%s' % (
|
||||
quote_plus(src_package),
|
||||
quote_plus(tgt_project),
|
||||
rev)))
|
||||
xml = http_GET(url).read()
|
||||
return xml
|
||||
|
||||
@memoize()
|
||||
@ -487,8 +484,9 @@ class CheckRepo(object):
|
||||
rq.updated = True
|
||||
continue
|
||||
|
||||
if (spec_info['project'] != rq.src_project
|
||||
or spec_info['package'] != rq.src_package) and not rq.updated:
|
||||
is_src_diff = (spec_info['project'] != rq.src_project or
|
||||
spec_info['package'] != rq.src_package)
|
||||
if is_src_diff and not rq.updated:
|
||||
msg = '%s/%s should _link to %s/%s' % (rq.src_project,
|
||||
spec,
|
||||
rq.src_project,
|
||||
@ -535,17 +533,18 @@ class CheckRepo(object):
|
||||
"""
|
||||
repos_to_check = []
|
||||
|
||||
root_xml = self.last_build_success(request.shadow_src_project,
|
||||
request.tgt_project,
|
||||
request.src_package,
|
||||
request.verifymd5)
|
||||
|
||||
if root_xml:
|
||||
root = ET.fromstring(root_xml)
|
||||
else:
|
||||
print ' - The request is not built agains this project'
|
||||
return repos_to_check
|
||||
try:
|
||||
root_xml = self.last_build_success(request.shadow_src_project,
|
||||
request.tgt_project,
|
||||
request.src_package,
|
||||
request.verifymd5)
|
||||
except urllib2.HTTPError as e:
|
||||
if 300 <= e.code <= 499:
|
||||
print ' - The request is not built agains this project'
|
||||
return repos_to_check
|
||||
raise e
|
||||
|
||||
root = ET.fromstring(root_xml)
|
||||
for repo in root.findall('repository'):
|
||||
intel_archs = [a for a in repo.findall('arch')
|
||||
if a.attrib['arch'] in ('i586', 'x86_64')]
|
||||
@ -716,7 +715,17 @@ class CheckRepo(object):
|
||||
|
||||
# If the request do not build properly in both Intel platforms,
|
||||
# return False.
|
||||
repos_to_check = self.repositories_to_check(request)
|
||||
try:
|
||||
repos_to_check = self.repositories_to_check(request)
|
||||
except urllib2.HTTPError as e:
|
||||
if 500 <= e.code <= 599:
|
||||
print ' - Temporal error in OBS: %s %s' % (e.code, e.msg)
|
||||
else:
|
||||
print ' - Unknown error in OBS: %s %s' % (e.code, e.msg)
|
||||
# Ignore this request until OBS error dissapears
|
||||
request.updated = True
|
||||
return False
|
||||
|
||||
if not repos_to_check:
|
||||
msg = 'Missing i586 and x86_64 in the repo list'
|
||||
print ' - %s' % msg
|
||||
|
@ -122,6 +122,8 @@ class FreezeCommand(object):
|
||||
|
||||
self.freeze_prjlinks()
|
||||
|
||||
build_status = self.api.get_flag_in_prj(prj, flag='build')
|
||||
|
||||
# If there is not a bootstrap repository, there is not
|
||||
# anything more to do.
|
||||
if not self.is_bootstrap():
|
||||
@ -149,6 +151,9 @@ class FreezeCommand(object):
|
||||
for arch in ['x86_64', 'ppc64le']:
|
||||
self.update_product_version(prj + ':DVD', 'Test-DVD-' + arch, arch, version)
|
||||
|
||||
# Set the original build status for the project
|
||||
self.api.build_switch_prj(prj, build_status)
|
||||
|
||||
def update_product_version(self, project, product, arch, version):
|
||||
if not self.api.item_exists(project, product):
|
||||
return None
|
||||
|
@ -40,7 +40,7 @@ except ImportError:
|
||||
CACHEDIR = save_cache_path('opensuse-repo-checker')
|
||||
|
||||
|
||||
def memoize(ttl=None, session=False, is_method=False):
|
||||
def memoize(ttl=None, session=False, add_invalidate=False):
|
||||
"""Decorator function to implement a persistent cache.
|
||||
|
||||
>>> @memoize()
|
||||
@ -172,7 +172,7 @@ def memoize(ttl=None, session=False, is_method=False):
|
||||
def total_seconds(td):
|
||||
return (td.microseconds + (td.seconds + td.days * 24 * 3600.) * 10**6) / 10**6
|
||||
now = datetime.now()
|
||||
if is_method:
|
||||
if add_invalidate:
|
||||
_self = args[0]
|
||||
_add_invalidate_method(_self)
|
||||
key = _key((args[1:], kwargs))
|
||||
|
@ -422,7 +422,7 @@ class StagingAPI(object):
|
||||
# self.accept_non_ring_request(rq)
|
||||
self.update_superseded_request(rq)
|
||||
|
||||
@memoize(ttl=60, session=True, is_method=True)
|
||||
@memoize(ttl=60, session=True, add_invalidate=True)
|
||||
def get_prj_pseudometa(self, project):
|
||||
"""
|
||||
Gets project data from YAML in project description
|
||||
@ -879,6 +879,17 @@ class StagingAPI(object):
|
||||
self.do_change_review_state(request_id, state, by_project=project,
|
||||
message=msg)
|
||||
|
||||
def get_flag_in_prj(self, project, flag='build', repository=None, arch=None):
|
||||
"""Return the flag value in a project."""
|
||||
url = self.makeurl(['source', project, '_meta'])
|
||||
root = ET.parse(http_GET(url)).getroot()
|
||||
section = root.find(flag)
|
||||
for status in section:
|
||||
is_repository = status.get('repository', None) == repository
|
||||
is_arch = status.get('arch', None) == arch
|
||||
if is_repository and is_arch:
|
||||
return status.tag
|
||||
|
||||
def switch_flag_in_prj(self, project, flag='build', state='disable', repository=None, arch=None):
|
||||
url = self.makeurl(['source', project, '_meta'])
|
||||
prjmeta = ET.parse(http_GET(url)).getroot()
|
||||
|
Loading…
x
Reference in New Issue
Block a user