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

[chore] Ensure file is closed in Supervisor test #35588

Merged

Conversation

evan-bradley
Copy link
Contributor

Description:

Follow up to #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.

Copy link
Contributor

@dpaasman00 dpaasman00 left a 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!

@BinaryFissionGames
Copy link
Contributor

BinaryFissionGames commented Oct 3, 2024

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.
uber-go/zap#434

@codeboten codeboten merged commit 2e04885 into open-telemetry:main Oct 3, 2024
177 of 178 checks passed
@github-actions github-actions bot added this to the next release milestone Oct 3, 2024
@codeboten
Copy link
Contributor

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

@evan-bradley evan-bradley deleted the fix-windows-file-closing branch October 3, 2024 17:49
@evan-bradley
Copy link
Contributor Author

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.

evan-bradley added a commit that referenced this pull request Oct 3, 2024
<!--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.
jriguera pushed a commit to springernature/opentelemetry-collector-contrib that referenced this pull request Oct 4, 2024
**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.
jriguera pushed a commit to springernature/opentelemetry-collector-contrib that referenced this pull request Oct 4, 2024
<!--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.
Eromosele-SM pushed a commit to sematext/opentelemetry-collector-contrib that referenced this pull request Oct 9, 2024
**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.
Eromosele-SM pushed a commit to sematext/opentelemetry-collector-contrib that referenced this pull request Oct 9, 2024
<!--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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmd/opampsupervisor Run Windows Enable running windows test on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants