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
Update Logrus to fix logging in tests #9712
Conversation
What's wrong with logrus 1.8.1? |
@zmb3 This sirupsen/logrus@ac6e35b |
I'm not sure I understand. So logrus had a race condition, they fixed it in 1.7.0, and then they rolled back the fix and the bug is present again? |
@zmb3 Pretty much. The one thing that can be not clear here is when the race happen. In order to trigger that behavior you need to call teleport/lib/config/configuration.go Line 472 in c7c9411
This is our internal fix gravitational/logrus@047e202 which matches code in 1.7.0. I checked the logrus history and they introduced the same fix around 1.6 I think and changed/reverted back to old form in 1.7.1 as a part of another fix. Probably the second option would be to not call |
Got it. I'm fine with this fix, was just trying to understand. Using the replace directive to pin the version is something I haven't seen before. Is that necessary? |
How does this relate to #9689? |
@zmb3 I don't think pinning in this way is very common, but AFAIK this is the only way to pin some dependency in Go to a particular version. On thing that is not clear about Go modules is what version of a modules is used when you build something, as GO doesn't allow a multiple version of the same library. For example, if we depend on logrus 1.7 then Go will use 1.7, unless one of our dependencies depends on logrus in a never version. Go will include a never version of logrus in our build (as or dependency require it), which we don't want to. Here is the documentation describing that https://go.dev/ref/mod#minimal-version-selection @espadolini I checked and I don't think that |
If we end up using the upstream |
lib/config/formatter.go
Outdated
@@ -342,7 +342,7 @@ func formatCallerWithPathAndLine() (path string) { | |||
return "" | |||
} | |||
|
|||
var frameIgnorePattern = regexp.MustCompile(`github\.com/(gravitational|(S|s)irupsen)/logrus`) | |||
var frameIgnorePattern = regexp.MustCompile(`github\.com/((S|s)irupsen)/logrus`) |
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.
Maybe we could drop the weird (S|s)
and do a case-insensitive match instead?
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 don't think that case-insensitive compare is a good fit as it's slower that the current one. But I also think we can drop S
at all. Currently the logrus package is called "github.com/sirupsen/logrus" and I don't think that anyone uses the old one anymore (I checked our current dependencies and I don't see it).
fe2159b
to
7007881
Compare
After talking with Roman I'm closing this PR in favor of #9738 |
After removing
vendor/
folder caller in our unit tests prints internal logger location instead of the real one where log was called, example:This bug was fixed upstream.
Until now we were using our own fork of logrus because of a race condition, but looks like this problem also has been fixed upstream: https://github.com/sirupsen/logrus/blame/v1.7.0/entry.go#L268-L279
I also updated the version in our API module as we're using there upstream version anyways.