-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Fix grpc recover and logging #155
Conversation
Thanks for looking this topic. I built the docker image based on your branch to run your fix, I think I missed something because I have the same log level as before. I also tried to pull to docker image built by the CI on the PR, but it does not work. Is the image published after the build on PRs?
|
Is there absolutely nothing nothing in the logs, or do you at least see the default lines like
No, the CI images aren't pushed |
I have normal logs, like on v0.6.0. Here is the output:
I think I should check my build, and maybe recreate it. |
Yeah, please try to confirm that your build does indeed include my changes. If it is though I'll have to go looking for how this can happen again. |
So yesterday I built master while thinking I was on your branch with the fix. I rebuilt the fix and now I have logs corresponding to the error. Thanks ! Do you think it could be possible to have new lines per
|
Thanks! So the callback handler doesn't handle the missing
The logging library currently escapes it automatically, which is necessary because the stacktrace is logged in the |
Actually we changed our OIDC provider so that it sends a I understand to point about the log output. Ok for me. This PR is good for me. 👏 |
Problem
While looking at #119 I discovered that the existing
RecoveryMiddleware
doesn't actually work for panics in gRPC code / API calls. This is because the grpc library handles the requests in goroutines, andrecover()
can only work for panics in the same goroutine.https://github.com/grpc/grpc-go/blob/431ea809a7676e1da8d09c33ae0d31fcba85f1ff/server.go#L920-L923
And while it does recover for non-gRPC calls, like the login flow, the logging doesn't actually work because
ctxlogrus
is a noop logger in this case.This can make setting up OIDC annoying like in #154, because it's just failing and not telling you why.
The OIDC callback handler is broken if the
name
claim is missing, despite it being optional in the spec and in the rest of the application.Changes
We handle a missing
name
claim in the OIDC User Info gracefully.RecoveryMiddleware
now logs usingtraces.Logger
, notctxlogrus
.For gRPC we make use of github.com/grpc-ecosystem/go-grpc-middleware's grpc_recovery interceptor to recover from panics. It has a custom handler to attach the trace id to the error message so it's visible to the client (e.g. in the
Grpc-Message
header).The log lines will look like this:
panic in gRPC API code:
panic in other HTTP handling code (actual log entry will have new lines escaped to
\n
):Fixes #118
Fixes #154