-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change transition order #131
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,7 +84,20 @@ func (r *Receiver) Notify(data *alertmanager.Data, hashJiraLabel bool) (bool, er | |
return false, errors.Wrap(err, "render issue description") | ||
} | ||
|
||
// Issue already exists. | ||
if issue != nil { | ||
|
||
// Issue is closed and should be reopened | ||
if issue.Fields.Status.StatusCategory.Key == "done" && issue.Fields.Resolution.Name != r.conf.WontFixResolution { | ||
level.Info(r.logger).Log("msg", "issue was recently resolved, reopening", "key", issue.Key, "label", issueGroupLabel) | ||
retry, err := r.reopen(issue.Key) | ||
if err != nil { | ||
return retry, err | ||
} | ||
// Issue is not dynamically updated, so we need to modify the Resolution to avoid creating duplicates on a "won't fix" situation | ||
issue.Fields.Resolution = nil | ||
} | ||
|
||
// Update summary if needed. | ||
if issue.Fields.Summary != issueSummary { | ||
retry, err := r.updateSummary(issue.Key, issueSummary) | ||
|
@@ -93,13 +106,22 @@ func (r *Receiver) Notify(data *alertmanager.Data, hashJiraLabel bool) (bool, er | |
} | ||
} | ||
|
||
// Update description if needed. | ||
if issue.Fields.Description != issueDesc { | ||
retry, err := r.updateDescription(issue.Key, issueDesc) | ||
if err != nil { | ||
return retry, err | ||
} | ||
} | ||
|
||
// Issue is set as won't fix. Discard. | ||
if r.conf.WontFixResolution != "" && issue.Fields.Resolution != nil && | ||
issue.Fields.Resolution.Name == r.conf.WontFixResolution { | ||
level.Info(r.logger).Log("msg", "issue was resolved as won't fix, not reopening", "key", issue.Key, "label", issueGroupLabel, "resolution", issue.Fields.Resolution.Name) | ||
return false, nil | ||
} | ||
Comment on lines
+117
to
+122
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this go at the very top? I.e. before the summary and/or description are updated? |
||
|
||
// Alert has been resolved. Close issue. | ||
if len(data.Alerts.Firing()) == 0 { | ||
if r.conf.AutoResolve != nil { | ||
level.Debug(r.logger).Log("msg", "no firing alert; resolving issue", "key", issue.Key, "label", issueGroupLabel) | ||
|
@@ -115,19 +137,11 @@ func (r *Receiver) Notify(data *alertmanager.Data, hashJiraLabel bool) (bool, er | |
} | ||
|
||
// The set of JIRA status categories is fixed, this is a safe check to make. | ||
if issue.Fields.Status.StatusCategory.Key != "done" { | ||
if issue.Fields.Resolution == nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand this either. Since the issue is about Jira not allowing editing issues in certain states (which presumably covers the summary and description), shouldn't the fix be to just move updating of the summary and description after the As is, the code first tries to reopen the issue (and edit it). Then it checks whether it should be reopened. Then resolves it, if no alerts are firing. Finally, if it has just reopened the issue, it logs "issue is unresolved" and exits. Seems kind of random. |
||
level.Debug(r.logger).Log("msg", "issue is unresolved, all is done", "key", issue.Key, "label", issueGroupLabel) | ||
return false, nil | ||
} | ||
|
||
if r.conf.WontFixResolution != "" && issue.Fields.Resolution != nil && | ||
issue.Fields.Resolution.Name == r.conf.WontFixResolution { | ||
level.Info(r.logger).Log("msg", "issue was resolved as won't fix, not reopening", "key", issue.Key, "label", issueGroupLabel, "resolution", issue.Fields.Resolution.Name) | ||
return false, nil | ||
} | ||
|
||
level.Info(r.logger).Log("msg", "issue was recently resolved, reopening", "key", issue.Key, "label", issueGroupLabel) | ||
return r.reopen(issue.Key) | ||
} | ||
|
||
if len(data.Alerts.Firing()) == 0 { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand this.