Skip to content

Commit

Permalink
added debug logging to NotificationManager (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
djcooke authored Jan 17, 2024
1 parent e30f923 commit 94319b2
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ private List<Notification> updateOpenIssues(Map<String, RunAndLibraries> data,
String runName = parseRunNameFromSummary(issue);
if (runName == null) {
// Issue doesn't seem to match expected pattern; ignore
log.warn("Unable to parse run name from JIRA ticket: {}", issue.getSummary());
continue;
}
log.debug("Processing existing JIRA ticket for {}", runName);
RunAndLibraries runAndLibraries = data.get(runName);
if (runAndLibraries == null) {
log.debug("Orphaned notification - run not found: {}", runName);
log.warn("Orphaned notification - run not found: {}", runName);
continue;
}
// track to avoid reprocessing later
Expand All @@ -130,6 +132,7 @@ private static String parseRunNameFromSummary(Issue issue) {
private void updateIssue(Issue issue, Notification notification, Counter jiraErrorCounter) {
try {
if (notification == null) {
log.debug("Closing issue: {}", issue.getSummary());
jiraService.closeIssue(issue, "All sign-offs have been completed.");
return;
}
Expand All @@ -138,12 +141,15 @@ private void updateIssue(Issue issue, Notification notification, Counter jiraErr
if (issueState != notificationState) {
switch (notificationState) {
case OPEN:
log.debug("Reopening issue: {}", issue.getSummary());
jiraService.reopenIssue(issue, notification.makeComment(baseUrl));
return;
case PAUSED:
log.debug("Pausing issue: {}", issue.getSummary());
jiraService.pauseIssue(issue, notification.makeComment(baseUrl));
return;
case CLOSED:
log.debug("Closing issue: {}", issue.getSummary());
jiraService.closeIssue(issue, notification.makeComment(baseUrl));
return;
default:
Expand All @@ -155,7 +161,10 @@ private void updateIssue(Issue issue, Notification notification, Counter jiraErr
Issue issueWithComments = jiraService.getIssueByKey(issue.getKey());
RunQcCommentSummary issueSummary = RunQcCommentSummary.findLatest(issueWithComments);
if (issueSummary == null || issueSummary.needsUpdate(notification)) {
log.debug("Commenting update on issue: {}", issue.getSummary());
jiraService.postComment(issue, notification.makeComment(baseUrl));
} else {
log.debug("No update necessary for issue: {}", issue.getSummary());
}
} catch (Exception e) {
jiraErrorCounter.increment();
Expand All @@ -177,7 +186,9 @@ private List<Notification> createOrReopenIssues(Map<String, RunAndLibraries> dat
newNotifications.add(x);
return;
}
String issueSummary = x.getRun().getName() + SUMMARY_SUFFIX_RUN_QC;
String runName = x.getRun().getName();
log.debug("Processing run without existing open ticket: {}", runName);
String issueSummary = runName + SUMMARY_SUFFIX_RUN_QC;
Issue issue = null;
try {
issue = jiraService.getIssueBySummary(issueSummary);
Expand All @@ -188,6 +199,7 @@ private List<Notification> createOrReopenIssues(Map<String, RunAndLibraries> dat
return;
}
if (issue == null) {
log.debug("Creating new JIRA ticket for {}", runName);
try {
String newIssueKey =
jiraService.createIssue(issueSummary, x.makeComment(baseUrl, resolutionOverride));
Expand All @@ -202,6 +214,8 @@ private List<Notification> createOrReopenIssues(Map<String, RunAndLibraries> dat
if (issueState != IssueState.OVERRIDDEN) {
updateIssue(issue, x, jiraErrorCounter);
newNotifications.add(x.withIssueKey(issue.getKey()));
} else {
log.debug("Aborting update on overridden JIRA ticket {}", issue.getSummary());
}
}
});
Expand Down

0 comments on commit 94319b2

Please sign in to comment.