diff --git a/changes/fix_jira-logging.md b/changes/fix_jira-logging.md new file mode 100644 index 000000000..44acc5350 --- /dev/null +++ b/changes/fix_jira-logging.md @@ -0,0 +1,2 @@ +Additional server logging for jira errors + diff --git a/plugin-jira/src/main/java/ca/on/oicr/gsi/shesmu/jira/IssueAction.java b/plugin-jira/src/main/java/ca/on/oicr/gsi/shesmu/jira/IssueAction.java index eaa53271d..4634337b9 100644 --- a/plugin-jira/src/main/java/ca/on/oicr/gsi/shesmu/jira/IssueAction.java +++ b/plugin-jira/src/main/java/ca/on/oicr/gsi/shesmu/jira/IssueAction.java @@ -120,6 +120,7 @@ public void labels(Set labels) { public ActionState perform( ActionServices services, Duration lastGeneratedByOlive, boolean isOliveLive) { if (connection == null) { + System.err.println("JIRA Connection for " + issueUrl + " is null."); return ActionState.FAILED; } final var current = connection.get(); diff --git a/plugin-jira/src/main/java/ca/on/oicr/gsi/shesmu/jira/IssueVerb.java b/plugin-jira/src/main/java/ca/on/oicr/gsi/shesmu/jira/IssueVerb.java index b948f29ae..4839dd58e 100644 --- a/plugin-jira/src/main/java/ca/on/oicr/gsi/shesmu/jira/IssueVerb.java +++ b/plugin-jira/src/main/java/ca/on/oicr/gsi/shesmu/jira/IssueVerb.java @@ -52,6 +52,13 @@ public ActionState perform( .orElse(false)) { bestMatch.accept(issue); if (!connection.transition(issue, Stream::anyMatch, comment)) { + StringBuilder errorBuilder = new StringBuilder(); + errorBuilder + .append("Unable to transition issue ") + .append(issue.getKey()) + .append("\nConnection: ") + .append(connection); + System.err.println(errorBuilder); return ActionState.FAILED; } } @@ -68,6 +75,11 @@ public boolean search(Pattern query) { public String verb() { return "Close"; } + + @Override + public String toString() { + return "Close JIRA Issue with comment " + comment; + } } public static class Open extends IssueVerb { @@ -149,6 +161,19 @@ public boolean search(Pattern query) { public String verb() { return "Open"; } + + @Override + public String toString() { + StringBuilder writeOut = new StringBuilder(); + writeOut + .append("Re/open JIRA Issue with description '") + .append(description) + .append("', reopen with comment '") + .append(comment) + .append("'"); + assignee.ifPresent(s -> writeOut.append(", with assignee '").append(s)); + return writeOut.toString(); + } } public abstract ActionState perform( diff --git a/plugin-jira/src/main/java/ca/on/oicr/gsi/shesmu/jira/JiraConnection.java b/plugin-jira/src/main/java/ca/on/oicr/gsi/shesmu/jira/JiraConnection.java index 19b703036..6253e35c1 100644 --- a/plugin-jira/src/main/java/ca/on/oicr/gsi/shesmu/jira/JiraConnection.java +++ b/plugin-jira/src/main/java/ca/on/oicr/gsi/shesmu/jira/JiraConnection.java @@ -341,12 +341,12 @@ public Stream> searches( .flatMap( search -> search - .getType() + .type() .join( - search.getName(), - search.getFilter().convert(builder), + search.name(), + search.filter().convert(builder), issues - .get(search.getJql()) + .get(search.jql()) .flatMap( issue -> { final var assignee = @@ -444,16 +444,26 @@ boolean transition( authenticationHeader.ifPresent( header -> commentRequestBuilder.header("Authorization", header)); - return CLIENT - .send( - commentRequestBuilder - .header("Content-Type", "application/json") - .POST(BodyPublishers.ofString(MAPPER.writeValueAsString(updateComment))) - .build(), - BodyHandlers.discarding()) - .statusCode() - / 100 - == 2; + var result = + CLIENT.send( + commentRequestBuilder + .header("Content-Type", "application/json") + .POST(BodyPublishers.ofString(MAPPER.writeValueAsString(updateComment))) + .build(), + BodyHandlers.ofString()); + boolean isGood = result.statusCode() / 100 == 2; + if (!isGood) { + StringBuilder errorBuilder = new StringBuilder(); + errorBuilder + .append("Unable to transition issue ") + .append(issue.getKey()) + .append(" using any of ") + .append(transitions) + .append("\nGot ") + .append(result.body()); + System.err.println(errorBuilder); + } + return isGood; } } return false; @@ -506,4 +516,34 @@ public Optional update(Configuration config) { public String url() { return url; } + + @Override + public String toString() { + StringBuilder writeOut = new StringBuilder(); + writeOut + .append("JiraConnection with closedStatuses = ") + .append(closedStatuses) + .append(", defaultFieldValues = ") + .append(defaultFieldValues.entrySet()) + .append(", definer = ") + .append(definer) + .append(", issueTypeId = ") + .append(issueTypeId) + .append(", issueTypeName = ") + .append(issueTypeName) + .append(", cached issues = ") + .append(issues) + .append(", projectId = ") + .append(projectId) + .append(", projectKey = ") + .append(projectKey) + .append(", searches = ") + .append(searches) + .append(", url = ") + .append(url) + .append(", version = ") + .append(version); + authenticationHeader.ifPresent(s -> writeOut.append(", authenticationHeader = ").append(s)); + return writeOut.toString(); + } } diff --git a/plugin-jira/src/main/java/ca/on/oicr/gsi/shesmu/jira/Search.java b/plugin-jira/src/main/java/ca/on/oicr/gsi/shesmu/jira/Search.java index 81f5761db..0332695d3 100644 --- a/plugin-jira/src/main/java/ca/on/oicr/gsi/shesmu/jira/Search.java +++ b/plugin-jira/src/main/java/ca/on/oicr/gsi/shesmu/jira/Search.java @@ -2,41 +2,4 @@ import ca.on.oicr.gsi.shesmu.plugin.filter.ActionFilter; -public final class Search { - private ActionFilter filter; - private String jql; - private String name; - private JoiningRule type; - - public ActionFilter getFilter() { - return filter; - } - - public String getJql() { - return jql; - } - - public String getName() { - return name; - } - - public JoiningRule getType() { - return type; - } - - public void setFilter(ActionFilter filter) { - this.filter = filter; - } - - public void setJql(String jql) { - this.jql = jql; - } - - public void setName(String name) { - this.name = name; - } - - public void setType(JoiningRule type) { - this.type = type; - } -} +public record Search(ActionFilter filter, String jql, String name, JoiningRule type) {} diff --git a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/cache/KeyValueCache.java b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/cache/KeyValueCache.java index 7961655d5..033d0bf65 100644 --- a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/cache/KeyValueCache.java +++ b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/cache/KeyValueCache.java @@ -169,4 +169,23 @@ public final void ttl(int ttl) { this.ttl = ttl; ttlValue.labels(name).set(ttl); } + + public String toString() { + StringBuilder writeOut = new StringBuilder(); + writeOut + .append(this.getClass()) + .append(" with CACHES = ") + .append(CACHES.entrySet()) + .append(", maxCount = ") + .append(maxCount) + .append(", name = ") + .append(name) + .append(", recordFactory = ") + .append(recordFactory) + .append(", records = ") + .append(records.entrySet()) + .append(", ttl = ") + .append(ttl); + return writeOut.toString(); + } } diff --git a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterIds.java b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterIds.java index 222eb787c..8aa3f3e06 100644 --- a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterIds.java +++ b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterIds.java @@ -30,4 +30,11 @@ public List getIds() { public void setIds(List ids) { this.ids = ids; } + + @Override + public String toString() { + StringBuilder writeOut = new StringBuilder(); + writeOut.append("Action filter for action identifier: ").append(ids); + return writeOut.toString(); + } } diff --git a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterOrphaned.java b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterOrphaned.java index 554afc996..0471ea0ce 100644 --- a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterOrphaned.java +++ b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterOrphaned.java @@ -10,4 +10,9 @@ public class ActionFilterOrphaned extends ActionFilter { public F convert(ActionFilterBuilder filterBuilder) { return filterBuilder.orphaned(); } + + @Override + public String toString() { + return "Action filter for orphaned actions"; + } } diff --git a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterRegex.java b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterRegex.java index 25c906f08..bdc493996 100644 --- a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterRegex.java +++ b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterRegex.java @@ -52,4 +52,13 @@ public void setMatchCase(boolean matchCase) { public void setPattern(String pattern) { this.pattern = pattern; } + + @Override + public String toString() { + StringBuilder writeOut = new StringBuilder(); + writeOut.append("Text matching regex filter of pattern: '").append(pattern).append("'"); + if (!matchCase) writeOut.append(" not"); + writeOut.append(" matching case"); + return writeOut.toString(); + } } diff --git a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterSourceFile.java b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterSourceFile.java index 01740d0bc..fe2a91ee6 100644 --- a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterSourceFile.java +++ b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterSourceFile.java @@ -2,6 +2,7 @@ import ca.on.oicr.gsi.shesmu.plugin.action.ActionState; import java.time.Instant; +import java.util.Arrays; import java.util.stream.Stream; /** @@ -32,4 +33,11 @@ public String[] getFiles() { public void setFiles(String[] files) { this.files = files; } + + @Override + public String toString() { + StringBuilder writeOut = new StringBuilder(); + writeOut.append("Source file action filter for file: ").append(Arrays.toString(files)); + return writeOut.toString(); + } } diff --git a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterSourceLocation.java b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterSourceLocation.java index d8e0052c8..e67245e9e 100644 --- a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterSourceLocation.java +++ b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterSourceLocation.java @@ -2,6 +2,7 @@ import ca.on.oicr.gsi.shesmu.plugin.action.ActionState; import java.time.Instant; +import java.util.Arrays; import java.util.stream.Stream; /** An action filter that checks if an action comes from a particular olive definition */ @@ -30,4 +31,13 @@ public SourceOliveLocation[] getLocations() { public void setLocations(SourceOliveLocation[] locations) { this.locations = locations; } + + @Override + public String toString() { + StringBuilder writeOut = new StringBuilder(); + writeOut + .append("Source location action filter for location: ") + .append(Arrays.toString(locations)); + return writeOut.toString(); + } } diff --git a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterStatus.java b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterStatus.java index 8acf63575..52777ad2d 100644 --- a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterStatus.java +++ b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterStatus.java @@ -2,6 +2,7 @@ import ca.on.oicr.gsi.shesmu.plugin.action.ActionState; import java.time.Instant; +import java.util.Arrays; import java.util.stream.Stream; /** An action filter that checks for actions in a particular state */ @@ -30,4 +31,11 @@ public ActionState[] getStates() { public void setState(ActionState[] states) { this.states = states; } + + @Override + public String toString() { + StringBuilder writeOut = new StringBuilder(); + writeOut.append("Action state filter for state: ").append(Arrays.toString(states)); + return writeOut.toString(); + } } diff --git a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterTag.java b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterTag.java index a6625369b..699fb2ae1 100644 --- a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterTag.java +++ b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterTag.java @@ -2,6 +2,7 @@ import ca.on.oicr.gsi.shesmu.plugin.action.ActionState; import java.time.Instant; +import java.util.Arrays; import java.util.stream.Stream; /** An action filter that checks if an action has a particular tag associated with it */ @@ -30,4 +31,11 @@ public String[] getTags() { public void setTags(String[] tags) { this.tags = tags; } + + @Override + public String toString() { + StringBuilder writeOut = new StringBuilder(); + writeOut.append("Tag filter for tags: ").append(Arrays.toString(tags)); + return writeOut.toString(); + } } diff --git a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterTagRegex.java b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterTagRegex.java index 07327674a..b1b764303 100644 --- a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterTagRegex.java +++ b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterTagRegex.java @@ -51,4 +51,13 @@ public void setMatchCase(boolean matchCase) { public void setPattern(String pattern) { this.pattern = pattern; } + + @Override + public String toString() { + StringBuilder writeOut = new StringBuilder(); + writeOut.append("Tag matching regex filter of pattern: '").append(pattern).append("'"); + if (!matchCase) writeOut.append(" not"); + writeOut.append(" matching case"); + return writeOut.toString(); + } } diff --git a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterText.java b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterText.java index 88174edb9..73cab61e1 100644 --- a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterText.java +++ b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterText.java @@ -47,4 +47,13 @@ public void setMatchCase(boolean matchCase) { public void setText(String text) { this.text = text; } + + @Override + public String toString() { + StringBuilder writeOut = new StringBuilder(); + writeOut.append("Text action filter for text: '").append(text).append("'"); + if (!matchCase) writeOut.append(" not"); + writeOut.append(" matching case"); + return writeOut.toString(); + } } diff --git a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterType.java b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterType.java index 811648b72..fe84f976a 100644 --- a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterType.java +++ b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/ActionFilterType.java @@ -2,6 +2,7 @@ import ca.on.oicr.gsi.shesmu.plugin.action.ActionState; import java.time.Instant; +import java.util.Arrays; import java.util.stream.Stream; /** Action filter to check an action's type */ @@ -30,4 +31,11 @@ public String[] getTypes() { public void setTypes(String[] types) { this.types = types; } + + @Override + public String toString() { + StringBuilder writeOut = new StringBuilder(); + writeOut.append("Action type filter of types: ").append(Arrays.toString(types)); + return writeOut.toString(); + } } diff --git a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/BaseAgoActionFilter.java b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/BaseAgoActionFilter.java index 72319533b..0b58db3bd 100644 --- a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/BaseAgoActionFilter.java +++ b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/BaseAgoActionFilter.java @@ -42,4 +42,11 @@ public final long getOffset() { public final void setOffset(long offset) { this.offset = offset; } + + @Override + public String toString() { + StringBuilder writeOut = new StringBuilder(); + writeOut.append(this.getClass()).append(" type filter of offset: ").append(offset); + return writeOut.toString(); + } } diff --git a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/BaseCollectionActionFilter.java b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/BaseCollectionActionFilter.java index b64f45c31..245d4be4a 100644 --- a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/BaseCollectionActionFilter.java +++ b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/BaseCollectionActionFilter.java @@ -2,6 +2,7 @@ import ca.on.oicr.gsi.shesmu.plugin.action.ActionState; import java.time.Instant; +import java.util.Arrays; import java.util.stream.Stream; /** Utility class for action filters that operate on a collection of other filters */ @@ -45,4 +46,15 @@ public final ActionFilter[] getFilters() { public final void setFilters(ActionFilter[] filters) { this.filters = filters; } + + @Override + public String toString() { + StringBuilder writeOut = new StringBuilder(); + writeOut + .append("Collection Action Filter (") + .append(this.getClass()) + .append(" of: ") + .append(Arrays.toString(filters)); + return writeOut.toString(); + } } diff --git a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/BaseRangeActionFilter.java b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/BaseRangeActionFilter.java index 29aa473e1..25f80247e 100644 --- a/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/BaseRangeActionFilter.java +++ b/shesmu-pluginapi/src/main/java/ca/on/oicr/gsi/shesmu/plugin/filter/BaseRangeActionFilter.java @@ -69,4 +69,17 @@ public final void setEnd(Long end) { public final void setStart(Long start) { this.start = start; } + + @Override + public String toString() { + StringBuilder writeOut = new StringBuilder(); + writeOut + .append("Range filter of type: ") + .append(this.getClass()) + .append(" between ") + .append(start) + .append(" and ") + .append(end); + return writeOut.toString(); + } }