Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Retry jira search
Browse files Browse the repository at this point in the history
  • Loading branch information
thegreyd committed Jul 7, 2023
1 parent 4463acd commit 4310cd6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions elliottlib/cli/find_bugs_kernel_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from bugzilla import Bugzilla
from bugzilla.bug import Bug
from jira import JIRA, Issue
from tenacity import retry, stop_after_attempt

from elliottlib import Runtime, brew
from elliottlib.assembly import AssemblyTypes
Expand All @@ -17,6 +18,10 @@
from elliottlib.bzutil import JIRABugTracker


@retry(reraise=True, stop=stop_after_attempt(3))
def _search_issues(jira_client, *args, **kwargs):
return jira_client.search_issues(*args, **kwargs)

class FindBugsKernelCli:
def __init__(self, runtime: Runtime, trackers: Sequence[str],
clone: bool, reconcile: bool, comment: bool, dry_run: bool):
Expand Down Expand Up @@ -106,7 +111,7 @@ def _find_kmaint_trackers(jira_client: JIRA, tracker_project: str, labels: List[
conditions.extend([f"labels = \"{label}\"" for label in labels])
jql = f'{" AND ".join(conditions)} ORDER BY created DESC'
# 50 most recently created KMAINT trackers should be more than enough
matched_issues = jira_client.search_issues(jql, maxResults=50)
matched_issues = _search_issues(jira_client, jql, maxResults=50)
return cast(List[Issue], matched_issues)

def _find_bugs(self, jira_client: JIRA, tracker: Issue, bz_client: Bugzilla, bz_target_releases: Sequence[str]):
Expand Down Expand Up @@ -158,7 +163,7 @@ def _clone_bugs(self, jira_client: JIRA, bugs: Sequence[Bug], conf: KernelBugSwe
kmaint_tracker_key = kmaint_tracker.key if kmaint_tracker else None
logger.info("Checking if %s was already cloned to OCP %s...", bug_id, ocp_target_release)
jql_str = f'project = {conf.project} and component = {conf.component} and labels = art:cloned-kernel-bug and labels = "art:bz#{bug_id}" and "Target Version" = "{ocp_target_release}" order by created DESC'
found_issues = cast(List[Issue], jira_client.search_issues(jql_str=jql_str))
found_issues = cast(List[Issue], _search_issues(jira_client, jql_str=jql_str))
if not found_issues: # this bug is not already cloned into OCP Jira
logger.info("Creating JIRA for bug %s...", bug.weburl)
fields = self._new_jira_fields_from_bug(bug, ocp_target_release, kmaint_tracker_key, conf)
Expand Down

0 comments on commit 4310cd6

Please sign in to comment.