Fix: Bugs in git.gerrit on nexus3 and sanity_check 05/70505/1 v0.36.2
authorEric Ball <eball@linuxfoundation.org>
Mon, 15 Aug 2022 21:10:42 +0000 (14:10 -0700)
committerEric Ball <eball@linuxfoundation.org>
Mon, 15 Aug 2022 21:10:42 +0000 (14:10 -0700)
Issue: RELENG-4366
Change-Id: I88f71ea3ffe746b46a5ee599db99aeee0e9bd3e8
Signed-off-by: Eric Ball <eball@linuxfoundation.org>
lftools/git/gerrit.py
releasenotes/notes/fix-gerrit-bugs-b993ae938e53dc6c.yaml [new file with mode: 0644]
tests/test_git.py

index fe593e7..df15eb6 100644 (file)
@@ -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 (file)
index 0000000..6849ab4
--- /dev/null
@@ -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.
index 7a8d9eb..450c063 100644 (file)
@@ -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)