From 506acf9980b34a2b1c83ce54524c17737f3b2547 Mon Sep 17 00:00:00 2001 From: Eric Ball Date: Mon, 15 Aug 2022 14:10:42 -0700 Subject: [PATCH] Fix: Bugs in git.gerrit on nexus3 and sanity_check Issue: RELENG-4366 Change-Id: I88f71ea3ffe746b46a5ee599db99aeee0e9bd3e8 Signed-off-by: Eric Ball --- lftools/git/gerrit.py | 8 +++++--- releasenotes/notes/fix-gerrit-bugs-b993ae938e53dc6c.yaml | 10 ++++++++++ tests/test_git.py | 3 +-- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/fix-gerrit-bugs-b993ae938e53dc6c.yaml diff --git a/lftools/git/gerrit.py b/lftools/git/gerrit.py index fe593e71..df15eb68 100644 --- a/lftools/git/gerrit.py +++ b/lftools/git/gerrit.py @@ -22,7 +22,6 @@ from git import Repo from jinja2 import Environment, PackageLoader, select_autoescape from lftools import config -from lftools.api.endpoints.gerrit import Gerrit as gerrit_api log = logging.getLogger(__name__) @@ -181,7 +180,6 @@ class Gerrit: gerrit_project test/test1 issue_id: CIMAN-33 """ - gerrit_api.sanity_check(None, self.fqdn, gerrit_project) filename = ".gitreview" jinja_env = Environment(loader=PackageLoader("lftools.git"), autoescape=select_autoescape()) @@ -200,7 +198,6 @@ class Gerrit: creds_path = "serverCredentialMappings.yaml" content_path = "content" sb_creds_path = "serverCredentialMappings.sandbox.yaml" - nexus3_ports = nexus3_ports.split(",") try: default_servers = config.get_setting(self.fqdn, "default_servers") @@ -232,6 +229,11 @@ class Gerrit: nexus3_ports = nexus3_ports.split(",") except configparser.NoOptionError: nexus3_ports = ["10001", "10002", "10003", "10004"] + elif nexus3_ports: + try: + nexus3_ports = nexus3_ports.split(",") + except AttributeError: + log.error("Invalid nexus3_ports designated.") jinja_env = Environment(loader=PackageLoader("lftools.git"), autoescape=select_autoescape()) template = jinja_env.get_template(params_path) diff --git a/releasenotes/notes/fix-gerrit-bugs-b993ae938e53dc6c.yaml b/releasenotes/notes/fix-gerrit-bugs-b993ae938e53dc6c.yaml new file mode 100644 index 00000000..6849ab46 --- /dev/null +++ b/releasenotes/notes/fix-gerrit-bugs-b993ae938e53dc6c.yaml @@ -0,0 +1,10 @@ +--- +fixes: + - | + Only attempt to split nexus3_ports after we've checked that they exist, and + wrap that attempt in a try/except so that bad ports won't break other parts + of the job. + - | + Remove all instances of the gerrit_api.sanity_check function. This is too + tightly coupled with other parts of the Gerrit API, and does not perform + correctly in the git class. diff --git a/tests/test_git.py b/tests/test_git.py index 7a8d9eb3..450c0631 100644 --- a/tests/test_git.py +++ b/tests/test_git.py @@ -14,7 +14,7 @@ import os import pytest -from lftools.git.gerrit import Gerrit, Repo, gerrit_api +from lftools.git.gerrit import Gerrit, Repo FIXTURE_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "fixtures") @@ -126,7 +126,6 @@ defaultbranch=master""" mocker.patch.object(Gerrit, "add_file") mocker.patch.object(Gerrit, "commit") - mocker.patch.object(gerrit_api, "sanity_check") mock_init.add_git_review(fqdn, gerrit_project, issue_id) -- 2.16.6