test: prevent logging panics from failing tests#2949
test: prevent logging panics from failing tests#2949theunrepentantgeek wants to merge 4 commits intokubernetes-sigs:mainfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: theunrepentantgeek The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @theunrepentantgeek! |
|
Hi @theunrepentantgeek. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Looks like this broke all of the tests. Does this belong in Karpenter or should this be something we cut an issue for upstream in go or the test frameworks? I haven't seen this happen personally, I'd like to see some evidence if possible |
Fixed - the
I created uber-go/zap #1526 about two months ago, but it hasn't gained much traction (if any). I have the changes in a WIP branch and will create a PR, but I'm not confident it will be merged.
Three examples from CI runs for We've suppressed a number of these test flakes by disabling certain log calls, effectively we're following this model: if !testing {
// log goes here
}But this has issues of it's own. |
Description
Depending on environmental timing issues, it's sometimes possible for goroutines launched as a part of a test to still be running (at least momentarily) after the test completes.
If one of those goroutines tries to log, the resulting panic can cause the entire test suite to fail.
This PR adds a safety wrapper around the logger to capture and suppress those panics, eliminating this cause of test flakes.
How was this change tested?
Full unit test coverage of
safeTestingT, plusmake testlocally (but noting that test flakes were normally observed during CI).By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.