-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[chore] Ensure file is closed in Supervisor test #35588
[chore] Ensure file is closed in Supervisor test #35588
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.
Ah nice, I just saw it was failing and wasn't sure why. Thanks!
Looks like the e2e windows tests got skipped in that last run: https://github.com/open-telemetry/opentelemetry-collector-contrib/actions/runs/11166244550/job/31039792977?pr=35588 I would be surprised if this was fixed by this, the defer should run before anything scheduled t.Cleanup calls happen. I suspect that the zap logger is actually holding the log file open, and not the test code. The fix might be a little more involved if that's the case. |
I think the change is still ok to merge even if it might not fix the issue. Would rather we ensure closing the log doesn't return an error |
Unfortunately it looks like this did not fix the issue. @BinaryFissionGames I was going to be a little surprised too, but thought that the test scheduler may be doing something strange to clean up tests before deferred statements can be run. Thanks for the pointer to Zap. It looks like Zap is indeed the culprit, since it doesn't keep any handles to close files it opens: https://github.com/uber-go/zap/blob/master/config.go#L316. I'll see if I can come up with another fix. |
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Follow up to #35588. This skips the test on Windows. The logic should be similar on other operating systems, so it's not a significant loss to skip it. The issue arises because Zap does not close log files itself and provides no handles to close them, so we would need to find a clever way to close the file or would need to simply not clean it up after the test executes.
**Description:** Follow up to open-telemetry#35468. This should fix issues like the following: ``` testing.go:1231: TempDir RemoveAll cleanup: remove C:\Users\RUNNER~1\AppData\Local\Temp\TestSupervisorInfoLoggingLevel3383092187\001\supervisor_log.log: The process cannot access the file because it is being used by another process. ``` I believe this error is caused by the temp directory doing a cleanup before all `defer` statements can run, but I'm not sure. This is how I've seen this error fixed in other tests.
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Follow up to open-telemetry#35588. This skips the test on Windows. The logic should be similar on other operating systems, so it's not a significant loss to skip it. The issue arises because Zap does not close log files itself and provides no handles to close them, so we would need to find a clever way to close the file or would need to simply not clean it up after the test executes.
**Description:** Follow up to open-telemetry#35468. This should fix issues like the following: ``` testing.go:1231: TempDir RemoveAll cleanup: remove C:\Users\RUNNER~1\AppData\Local\Temp\TestSupervisorInfoLoggingLevel3383092187\001\supervisor_log.log: The process cannot access the file because it is being used by another process. ``` I believe this error is caused by the temp directory doing a cleanup before all `defer` statements can run, but I'm not sure. This is how I've seen this error fixed in other tests.
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Follow up to open-telemetry#35588. This skips the test on Windows. The logic should be similar on other operating systems, so it's not a significant loss to skip it. The issue arises because Zap does not close log files itself and provides no handles to close them, so we would need to find a clever way to close the file or would need to simply not clean it up after the test executes.
Description:
Follow up to #35468. This should fix issues like the following:
I believe this error is caused by the temp directory doing a cleanup before all
defer
statements can run, but I'm not sure. This is how I've seen this error fixed in other tests.