From c0b6e33b49b633678dc8b13c311b512f75afb049 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 May 2017 13:00:04 -0400 Subject: [PATCH] protect against repos where we can't get project name Some of the older released versions of projects don't work when we run 'python setup.py --name' (disk-image-builder was the main one I noticed). This patch protects against those exceptions, and reports them as warnings if the release is already tagged and errors if it is a new release. Change-Id: Iaa47e7ea2a52efee200e8c710c3660a7893b5147 Signed-off-by: Doug Hellmann --- openstack_releases/cmds/validate.py | 55 ++++++++++++++++++----------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/openstack_releases/cmds/validate.py b/openstack_releases/cmds/validate.py index 3bbd7086f6..6228c8905d 100644 --- a/openstack_releases/cmds/validate.py +++ b/openstack_releases/cmds/validate.py @@ -341,35 +341,48 @@ def validate_releases(deliverable_info, zuul_layout, # remotely. gitutils.clone_repo(workdir, project['repo'], project['hash']) + version_exists = gitutils.tag_exists( + project['repo'], release['version'], + ) + # Check that the sdist name and tarball-base name match. if link_mode == 'tarball': - sdist = pythonutils.get_sdist_name(workdir, - project['repo']) - if sdist is not None: - expected = project.get( - 'tarball-base', - os.path.basename(project['repo']), - ) - if sdist != expected: - if 'tarball-base' in project: - action = 'is set to' - else: - action = 'defaults to' - mk_error( - ('tarball-base for %s %s %s %r ' - 'but the sdist name is actually %r. ' + - _PLEASE) - % (project['repo'], release['version'], - action, expected, sdist)) + try: + sdist = pythonutils.get_sdist_name(workdir, + project['repo']) + except Exception as err: + msg = 'Could not get the name of {} for version {}: {}'.format( + project['repo'], release['version'], err) + if version_exists: + # If there was a problem with an existing + # release, treat it as a warning so we + # don't prevent new releases. + mk_warning(msg) + else: + mk_error(msg) + else: + if sdist is not None: + expected = project.get( + 'tarball-base', + os.path.basename(project['repo']), + ) + if sdist != expected: + if 'tarball-base' in project: + action = 'is set to' + else: + action = 'defaults to' + mk_error( + ('tarball-base for %s %s %s %r ' + 'but the sdist name is actually %r. ' + + _PLEASE) + % (project['repo'], release['version'], + action, expected, sdist)) # Report if the version has already been # tagged. We expect it to not exist, but neither # case is an error because sometimes we want to # import history and sometimes we want to make new # releases. - version_exists = gitutils.tag_exists( - project['repo'], release['version'], - ) if version_exists: actual_sha = gitutils.sha_for_tag( workdir,