Skip to content

Commit

Permalink
Fix: Bugs in git.gerrit on nexus3 and sanity_check
Browse files Browse the repository at this point in the history
Issue: RELENG-4366
Change-Id: I88f71ea3ffe746b46a5ee599db99aeee0e9bd3e8
Signed-off-by: Eric Ball <[email protected]>
  • Loading branch information
eb-oss committed Aug 15, 2022
1 parent 9fad87b commit 506acf9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
8 changes: 5 additions & 3 deletions lftools/git/gerrit.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
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__)

Expand Down Expand Up @@ -181,7 +180,6 @@ def add_git_review(self, fqdn, gerrit_project, issue_id):
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())
Expand All @@ -200,7 +198,6 @@ def add_maven_config(self, fqdn, gerrit_project, issue_id, nexus3_url="", nexus3
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")
Expand Down Expand Up @@ -232,6 +229,11 @@ def add_maven_config(self, fqdn, gerrit_project, issue_id, nexus3_url="", nexus3
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)
Expand Down
10 changes: 10 additions & 0 deletions releasenotes/notes/fix-gerrit-bugs-b993ae938e53dc6c.yaml
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 1 addition & 2 deletions tests/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

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")

Expand Down Expand Up @@ -126,7 +126,6 @@ def test_add_git_review(mock_init, datafiles, mocker):

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)

Expand Down

0 comments on commit 506acf9

Please sign in to comment.