Merge "Skip retry loop on first check for group"

This commit is contained in:
Jenkins 2017-02-17 14:42:01 +00:00 committed by Gerrit Code Review
commit 9ae0c06299
1 changed files with 5 additions and 4 deletions

View File

@ -176,7 +176,7 @@ def push_acl_config(project, remote_url, repo_path, gitid, env=None):
return True
def _get_group_uuid(group):
def _get_group_uuid(group, retries=10):
"""
Gerrit keeps internal user groups in the DB while it keeps systems
groups in All-Projects groups file (in refs/meta/config). This
@ -189,7 +189,7 @@ def _get_group_uuid(group):
"""
query = "SELECT group_uuid FROM account_groups WHERE name = %s"
con = jeepyb.gerritdb.connect()
for x in range(10):
for x in range(retries):
cursor = con.cursor()
cursor.execute(query, (group,))
data = cursor.fetchone()
@ -197,12 +197,13 @@ def _get_group_uuid(group):
con.commit()
if data:
return data[0]
time.sleep(1)
if retries > 1:
time.sleep(1)
return None
def get_group_uuid(gerrit, group):
uuid = _get_group_uuid(group)
uuid = _get_group_uuid(group, retries=1)
if uuid:
return uuid
if group in GERRIT_SYSTEM_GROUPS: