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

Fix project cache plugin exception handling #6345

Merged
merged 4 commits into from
Apr 23, 2021

Conversation

cdmihai
Copy link
Contributor

@cdmihai cdmihai commented Apr 14, 2021

Context

The project cache plugin can fail with exceptions from any of its APIs. Currently some exceptions from certain APIs get lost and the build fails with no errors.

This PR ensures that:

  • no exceptions get lost
  • the build is marked as failed when any plugin API fails

Changes Made

  • BuildManager.ExecuteSubmission(BuildSubmission) always completes the build submission with the exception when it detects that it's running in a detached thread.
  • BuildManager.BuildGraph observes the exceptions captured above and rethrows them to mimic what happens when ExecuteSubmission(BuildSubmission) does not run in a detached thread.
  • BuildManager.EndBuild marks the overall build result as failed if exceptions are thrown in BM.EndBuild.

Testing

Added unit tests to ensure that exceptions thrown from any possible plugin API are observable.

Notes

This is an intermediary implementation to avoid lost exceptions. A better implementation which I'm working on, builds upon this one and actually logs the plugin exceptions to the LoggingService in a similar way to which logger errors get handled.

Copy link
Member

@Forgind Forgind left a comment

Choose a reason for hiding this comment

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

LGTM

StringShouldContainSubstring(logger.FullLog, $"{AssemblyMockCache}: EndBuildAsync", expectedOccurrences: 1);
}

// TODO: this ain't right now is it?
Copy link
Member

Choose a reason for hiding this comment

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

To be done in the follow-up PR, or is this leftover? 🤔

Copy link
Contributor Author

@cdmihai cdmihai Apr 22, 2021

Choose a reason for hiding this comment

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

Yup, followup-pr: #6368
This PR just fixes the exception handling part, follow-up PR does the logging.

@benvillalobos benvillalobos added the merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now. label Apr 22, 2021
@benvillalobos benvillalobos merged commit 117a9cb into dotnet:main Apr 23, 2021
@cdmihai cdmihai deleted the fixPluginExceptionHandling branch April 23, 2021 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants