-
Notifications
You must be signed in to change notification settings - Fork 793
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
Push NATS error messages to error queue #724
Conversation
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.
Looks great! Some very minor comments below, but other than that good to go 👍
mqtrigger/messageQueue/nats.go
Outdated
if err != nil { | ||
log.Warningf("Request failed: %v", url) | ||
var resp *http.Response | ||
for attempt := -1; attempt < trigger.Spec.MaxRetries; attempt++ { |
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.
This is entirely subjective but I'd have this loop go attempt := 0; attempt <= trigger.Spec.MaxRetries; ...
mqtrigger/messageQueue/nats.go
Outdated
var resp *http.Response | ||
for attempt := -1; attempt < trigger.Spec.MaxRetries; attempt++ { | ||
// Make the request | ||
log.Warningf("Request : %v", req) |
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.
remove
mqtrigger/messageQueue/nats.go
Outdated
} | ||
|
||
if resp == nil { | ||
log.Warning("The response was undefined. Quit.") |
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.
This means every retry failed, right? That's probably a better log message.
mqtrigger/messageQueue/nats.go
Outdated
return | ||
} | ||
|
||
// TODO : Sequence |
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.
Hm?
mqtrigger/messageQueue/nats.go
Outdated
log.Printf("Request returned failure: %v", resp.StatusCode) | ||
return | ||
|
||
// TODO : what if err is not nil, then body is empty. publish either of them, not just body. |
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.
We shouldn't mix those errors into the same queue, simply avoiding publishing when body is empty is probably good enough.
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.
This comment was actually added by @smruthi2187. I can remove this TODO and check if the body is empty before publishing.
mqtrigger/messageQueue/nats.go
Outdated
|
||
// Only the latest error response will be published to error topic | ||
if err != nil || resp.StatusCode != 200 { | ||
if len(trigger.Spec.ErrorTopic) > 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.
&& len(body) > 0
Reviewed 4 of 6 files at r1, 2 of 2 files at r2. fission/main.go, line 197 at r2 (raw file):
Use "Value" to set the default value 0 like
fission/mqtrigger.go, line 163 at r2 (raw file):
This line should be removed or it will overwrite previously maxRetries setting if maxRetries has been set. mqtrigger/messageQueue/nats.go, line 133 at r2 (raw file):
Print error message if err is not nil mqtrigger/messageQueue/nats.go, line 139 at r2 (raw file):
Suggest using HTTP status const for the status code. (https://golang.org/pkg/net/http/#pkg-constants). Comments from Reviewable |
Review status: 3 of 6 files reviewed, 11 unresolved discussions (waiting on @life1347, @soamvasani, and @Amusement) mqtrigger/messageQueue/nats.go, line 133 at r3 (raw file):
We also need to print some useful information for debugging, how about
Comments from Reviewable |
Review status: 2 of 6 files reviewed, 11 unresolved discussions (waiting on @life1347, @soamvasani, and @Amusement) fission/mqtrigger.go, line 163 at r2 (raw file): Previously, life1347 (Ta-Ching Chen) wrote…
Done. mqtrigger/messageQueue/nats.go, line 129 at r1 (raw file): Previously, soamvasani (Soam Vasani) wrote…
Done. mqtrigger/messageQueue/nats.go, line 131 at r1 (raw file): Previously, soamvasani (Soam Vasani) wrote…
Done. mqtrigger/messageQueue/nats.go, line 144 at r1 (raw file): Previously, soamvasani (Soam Vasani) wrote…
Done. mqtrigger/messageQueue/nats.go, line 157 at r1 (raw file): Previously, Amusement (Nafisa Shazia) wrote…
Done. mqtrigger/messageQueue/nats.go, line 161 at r1 (raw file): Previously, soamvasani (Soam Vasani) wrote…
Done. mqtrigger/messageQueue/nats.go, line 133 at r2 (raw file): Previously, life1347 (Ta-Ching Chen) wrote…
Done. mqtrigger/messageQueue/nats.go, line 139 at r2 (raw file): Previously, life1347 (Ta-Ching Chen) wrote…
Done. mqtrigger/messageQueue/nats.go, line 133 at r3 (raw file): Previously, life1347 (Ta-Ching Chen) wrote…
Done. Comments from Reviewable |
Review status: 2 of 6 files reviewed, 11 unresolved discussions (waiting on @life1347 and @soamvasani) fission/main.go, line 197 at r2 (raw file): Previously, life1347 (Ta-Ching Chen) wrote…
Done. mqtrigger/messageQueue/nats.go, line 148 at r1 (raw file): Previously, soamvasani (Soam Vasani) wrote…
Done. Comments from Reviewable |
LGTM |
Addressed comments -- removed max retries cap, improved error handling.
This change is