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

[automation/dotnet] Fix EventLogWatcher failing to read events after an exception was thrown #6821

Merged

Conversation

vipentti
Copy link
Contributor

Discovered this while trying to preview some code which threw an exception. Instead of propagating the actual exception to the caller, the following exception was thrown

System.IO.IOException : The process cannot access the file '<temp>\automation-logs-preview-bc4fcvtm.ayq\eventlog.txt' 
because it is being used by another process.

This error seems to only occur on Windows.

@github-actions
Copy link

PR is now waiting for a maintainer to run the acceptance tests.

Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

@github-actions
Copy link

PR is now waiting for a maintainer to run the acceptance tests.

Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

@@ -91,7 +91,7 @@ private async Task ReadEventsOnce()
return;
}

using var fs = new FileStream(LogFile, FileMode.Open, FileAccess.Read)
using var fs = new FileStream(LogFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
Copy link
Contributor Author

@vipentti vipentti Apr 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure why this fixes it at least when testing locally. Basically without this, the ExceptionPropagatesToCaller tests would always fail on Windows 10 with the exception. Adding FileShare.ReadWrite fixes this and the tests pass

@komalali komalali requested a review from t0yv0 April 22, 2021 00:56
Copy link
Member

@t0yv0 t0yv0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome thanks for this!

I wonder what's up with this tests not failing on CI or maybe it's not running on CI? Checking.

@t0yv0
Copy link
Member

t0yv0 commented Apr 22, 2021

/run-acceptance-tests

@github-actions
Copy link

PR is now waiting for a maintainer to run the acceptance tests.

Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

@github-actions
Copy link

Please view the results of the PR Build + Acceptance Tests Run Here

@vipentti
Copy link
Contributor Author

@t0yv0 The problem only occurs when event-log is used, which by default only happens during preview, which was not previously used in the error propagation test cases so I think that's why it was not happening in CI.

@t0yv0
Copy link
Member

t0yv0 commented Apr 22, 2021

Gotcha so we needed the test change to repro. Awesome. Thanks again for this.

@vipentti
Copy link
Contributor Author

The problem should be reproducible by removing the FileShare.ReadWrite and running the tests on a Windows machine.

@github-actions
Copy link

Please view the results of the PR Build + Acceptance Tests Run Here

@github-actions
Copy link

PR is now waiting for a maintainer to run the acceptance tests.

Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

@t0yv0 t0yv0 merged commit 52fb4c2 into pulumi:master Apr 26, 2021
abhinav pushed a commit to pulumi/pulumi-dotnet that referenced this pull request Jan 11, 2023
…an exception was thrown (pulumi/pulumi#6821)

* [automation/dotnet] Fix EventLogWatcher failing to read events after exception

* Update CHANGELOG_PENDING.md

Co-authored-by: Anton Tayanovskyy <anton@pulumi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants