Skip to content

Conversation

@DmitriyShepelev
Copy link
Contributor

@DmitriyShepelev DmitriyShepelev commented Dec 15, 2022

Context

Support a laxer isolation mode -isolate:MessageUponIsolationViolation (or its short form -isolate:Message) for builds unable to adhere to the restrictive isolation mode -isolate:True, piggybacking on the existing skipStaticGraphIsolationConstraints flag. Isolation violations are logged as messages.

Changes

  • Allow a new value for the -isolate switch: MessageUponIsolationViolation (short form Message).
  • In this new mode, only the TargetResults for top-level targets are serialized into the output cache. This is to mitigate the chances of isolation-violating dependency targets relying on state potentially mutated by cached dependency targets. (E.g., the definition of a property.) As such, it is still possible for a dependent project to have a config entry C in its override caches and still need to obtain BuildResults from C in isolation violation, requiring placing them in the override result cache instead of the current cache to maintain the invariant of no overlap configs across the override and current caches.
  • Preserve the IsolateProjects getter/setter for API backwards compat.

@DmitriyShepelev
Copy link
Contributor Author

DmitriyShepelev commented Dec 19, 2022

Discussed offline with @Forgind and @dfederm:

  1. Avert making breaking change to the BuildParameters.IsolateProjects.get API by wrapping existing isolateProjects boolean with the created ProjectIsolationMode enum.
    2. When dependent project P1 needs to obtain the cache results for targets t1, t2, ..., tm from a dependency project P2 for which P1 already has cache results for targets tm+1, tm+2, ..., tn such that m > 0 and m < n, the cache results for tm+1, tm+2, ..., tn are invalidated and all targets in P2 are built as if -isolate was set to False. This is to prevent incorrect behavior, such as that covered by the no-longer-necessary MSB4047. Note that this change means that the other bug fix regarding not placing any isolation-violating target results into the current cache if the corresponding project's configuration already exists in the override cache is no longer necessary.
  2. Placing the bug fix for excluding the cache results for dependency projects built in violation of isolation mode from the output cache file into a separate PR.

JaynieBai pushed a commit that referenced this pull request Jan 10, 2023
…4386) (#8257)

Fixes #4386

Context
Any cache entries from projects excluded from isolation constraints should be excluded from the output results cache file.

Changes Made
Only the cache entry with the smallest configuration ID (that of the project to be built in isolation) should be serialized into the output results cache file. As described in #4386, this prevents the case where dependency projects pass down the same cache entry obtained through skipping/violating isolation constraints to a dependent project, creating duplicate input cache entries.

Testing
Added a UT.

Notes
Addressing this issue since it came up frequently when testing #8249.
Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

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

I'm very confused by the Targets list and would like clarity on that before digging back in.

Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

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

Overall LGTM but some comments to clarify the fairly complicated flow and tests here would be highly appreciated.

@DmitriyShepelev DmitriyShepelev force-pushed the isolate-with-messaging branch 2 times, most recently from bf03174 to c6df3fb Compare January 24, 2023 17:05
@rainersigwald rainersigwald 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 Jan 25, 2023
@JaynieBai JaynieBai merged commit 16cf4b1 into dotnet:main Feb 6, 2023
JaynieBai pushed a commit that referenced this pull request Feb 7, 2023
…#8330)

Fixes #4252

Context
This PR extracts the relevant logic from the closed #5297, which adds support for the SkipNonexistentTargets metadatum on the ProjectReferenceTargets item:

<ProjectReferenceTargets Include='<some-target>' Targets='<some-target1>;<some-target2>' SkipNonexistentTargets='<boolean>'>
If SkipNonexistentTargets is true, then any targets in Targets are skipped if they're nonexistent. SkipNonexistentTargets cannot be added to ProjectReferenceTargets items whose Targets contain .default or .projectReferenceTargetsOrDefaultTargets, which represent the default targets and targets specified on the ProjectReference item (with fallback to default targets if none are specified), respectively.

Changes Made
GetTargetLists filters out skippable nonexistent targets on referenced projects.
Determining whether a target is skippable required storing the defined project targets in BuildResults to ensure that corresponding BuildRequestConfigurations on the build manager node have set project targets if the build manager node created a configuration based on a request from an external node but hadn't received a result (since the project may not have been loaded locally and thus the project targets would be unknown).
Added SkipNonexistentTargets='true' to GetTargetFrameworks since in the non-graph case it is added to the relevant MSBuild task.
Testing
UTs and manual testing with /graph and /graph /isolate (the latter run without restore being called due to #6856) on the erroring repos I saw when testing #8249.

Notes
Addressing this since it came up when testing #8249.
@DmitriyShepelev DmitriyShepelev deleted the isolate-with-messaging branch February 13, 2023 22:56
JaynieBai pushed a commit that referenced this pull request Apr 19, 2023
Update documentation given the merge of #8249, #8257, and #8330.

---------

Co-authored-by: Rainer Sigwald <[email protected]>
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.

5 participants