Skip to content
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

gateway: degrade error in gateway to log to reduce noise #2971

Merged
merged 3 commits into from
Nov 16, 2016

Conversation

Kubuxu
Copy link
Member

@Kubuxu Kubuxu commented Jul 15, 2016

It logs all errors including expired IPNS keys and other non important
errors.

License: MIT
Signed-off-by: Jakub Sztandera kubuxu@protonmail.ch

@Kubuxu Kubuxu force-pushed the feature/gateway-resolve-error branch from 1391440 to c1f7428 Compare July 15, 2016 11:37
@@ -506,7 +506,7 @@ func webError(w http.ResponseWriter, message string, err error, defaultCode int)

func webErrorWithCode(w http.ResponseWriter, message string, err error, code int) {
w.WriteHeader(code)
log.Errorf("%s: %s", message, err) // TODO(cryptix): log errors until we have a better way to expose these (counter metrics maybe)
log.Infof("%s: %s", message, err) // TODO(cryptix): log until we have a better way to expose these (counter metrics maybe)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we split out this TODO into an issue?

@ghost
Copy link

ghost commented Jul 15, 2016

I think this is probably insufficient. Some of these are legitimate errors, some are just totally normal from the gateway's perspective. Error handling in the gateway generally needs to be reworked.

@ghost
Copy link

ghost commented Jul 15, 2016

But 👍 LGTM, since it reduces log noise.

@Kubuxu
Copy link
Member Author

Kubuxu commented Jul 15, 2016

It does and that is what #2972 is for.

@Kubuxu Kubuxu added the RFM label Jul 15, 2016
@whyrusleeping
Copy link
Member

I agree with @lgierth here, i dont think this is what we want to do. We should filter out explictly which errors we want to demote, this was here for a reason, we want to know when something has gone wrong and handle it accordingly.

@whyrusleeping whyrusleeping removed the RFM label Jul 15, 2016
@Kubuxu Kubuxu force-pushed the feature/gateway-resolve-error branch from c1f7428 to 919d835 Compare July 16, 2016 11:41
@Kubuxu
Copy link
Member Author

Kubuxu commented Jul 16, 2016

Reworked it.

@Kubuxu Kubuxu added the need/review Needs a review label Jul 16, 2016
@@ -158,6 +159,11 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
w.WriteHeader(http.StatusServiceUnavailable)
fmt.Fprint(w, "Could not resolve path. Node is in offline mode.")
return
} else if err == namesys.ErrResolveFailed {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets change this over to an error switch

@whyrusleeping
Copy link
Member

We might also want to handle context deadline exceeded errors (i see these somewhat often too) and add some tests.

@whyrusleeping whyrusleeping added need/author-input Needs input from the original author and removed need/review Needs a review labels Aug 4, 2016
@jbenet
Copy link
Member

jbenet commented Aug 4, 2016

+1 to being very explicit about what's getting demoted and making
absolutely sure it's not a problematic condition users should be made aware
of. (What @lgierth said)
On Thu, Aug 4, 2016 at 10:11 Jeromy Johnson notifications@github.com
wrote:

We might also want to handle context deadline exceeded errors (i see these
somewhat often too) and add some tests.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#2971 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAIcoT8XDsvUA9qMT0kegwGzEp0qUHpAks5qcfMpgaJpZM4JNUN_
.

@Kubuxu Kubuxu force-pushed the feature/gateway-resolve-error branch from 919d835 to 51e55d7 Compare September 8, 2016 09:14
@Kubuxu Kubuxu added need/review Needs a review and removed need/author-input Needs input from the original author labels Sep 8, 2016
@Kubuxu
Copy link
Member Author

Kubuxu commented Sep 8, 2016

Updated.

@Kubuxu Kubuxu removed their assignment Sep 8, 2016
case nil:
// core.Resolve worked
case core.ErrNoNamesys:
if !i.node.OnlineMode() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if we get ErrNoNamesys and we're 'online' ? Even if this can never happen we should still check that case here and log an error

@Kubuxu Kubuxu self-assigned this Sep 9, 2016
@Kubuxu Kubuxu force-pushed the feature/gateway-resolve-error branch from 20d4bf5 to bba2a85 Compare September 12, 2016 11:24
@Kubuxu
Copy link
Member Author

Kubuxu commented Sep 12, 2016

Updated

@Kubuxu Kubuxu removed their assignment Sep 12, 2016
@Kubuxu Kubuxu force-pushed the feature/gateway-resolve-error branch from bba2a85 to 9124d2e Compare September 12, 2016 11:25
@whyrusleeping whyrusleeping added the status/in-progress In progress label Sep 14, 2016
@Kubuxu
Copy link
Member Author

Kubuxu commented Oct 3, 2016

@lgierth can you CR on this?

@whyrusleeping
Copy link
Member

LGTM, just waiting on a 👍 from @lgierth

// core.Resolve worked
case namesys.ErrResolveFailed:
// Don't log that error as it is just noise
w.WriteHeader(http.StatusBadRequest)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

400 doesn't fit here since the 4xx range is for client errors, where the client can amend the request to possibly get a successful response. 502 Bad Gateway or, (less specific) 500 Internal Server Error would be sufficient.

Copy link
Member Author

@Kubuxu Kubuxu Oct 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ErrResolveFailed means that the link passed by client can't be resolved, this doesn't mean it is server fault that it can't be resolved.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Poor server, we're blaming everything on it :P The meaning of a 4xx for the client is "don't retry unless you make changes to the request" though, and the reason for ErrResolveFailed can be an invalid /ipns string, or a failure in DNS resolution.

Anyhow, I don't have strong feelings about it right now, because the 400 status here doesn't regress from what we already have. We obviously need more granular errors through the stack though.

}
fallthrough
default:
// all other erros
webError(w, "Path Resolve error", err, http.StatusBadRequest)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay to leave this existing line with 400 for now, but the same applies here.

@Kubuxu
Copy link
Member Author

Kubuxu commented Oct 4, 2016

@lgierth updated

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks LGTM 👍

@Kubuxu
Copy link
Member Author

Kubuxu commented Oct 5, 2016

Wait, it broke the tests...

@Kubuxu
Copy link
Member Author

Kubuxu commented Oct 24, 2016

@lgierth can you confirm change in behaviour here:

--- FAIL: TestGatewayGet (0.01s)
    gateway_test.go:127: http://127.0.0.1:52637
    gateway_test.go:156: got 500, expected 400 from http://localhost:5001/ipns/nxdomain.example.com

@Kubuxu Kubuxu assigned ghost and unassigned Kubuxu Oct 24, 2016
@ghost ghost added the topic/gateway Topic gateway label Oct 28, 2016
@whyrusleeping whyrusleeping added status/ready Ready to be worked and removed status/in-progress In progress labels Nov 2, 2016
It logs all errors including expired IPNS keys and other non important
errors.

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
@ghost ghost force-pushed the feature/gateway-resolve-error branch from 1ad08da to 63ea995 Compare November 16, 2016 04:29
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
@ghost ghost force-pushed the feature/gateway-resolve-error branch from 63ea995 to ce96b91 Compare November 16, 2016 04:37
@ghost
Copy link

ghost commented Nov 16, 2016

This LGTM 👍, I went and resolved the conflicts with the recent coreapi changes, @Kubuxu I thought that's likely okay :)

Sorry for sitting on it so long!

@whyrusleeping whyrusleeping merged commit 4cfd841 into master Nov 16, 2016
@whyrusleeping whyrusleeping deleted the feature/gateway-resolve-error branch November 16, 2016 09:00
@whyrusleeping whyrusleeping removed the status/ready Ready to be worked label Nov 16, 2016
@ghost ghost mentioned this pull request Dec 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/review Needs a review topic/gateway Topic gateway
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants