Skip to content

Fix baseline manifest version for RTM branding #43737

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

Merged

Conversation

dsplaisted
Copy link
Member

In #43483, we hit a test failure where a workload uninstall command was failing. On investigation, this was because during the SDK build when the baseline workload set was being created, its feature band was being calculated incorrectly. This led to the workload set being included in a folder such as sdk-manifests\9.0.100-rtm.24476\workloadsets\9.0.100-rtm.24476.1, using 9.0.100-rtm.24476 for the feature band instead of 9.0.100 which would have been correct.

When the SDK scanned for workload sets it would find this as workload set 9.0.100-rtm.24476.1, but when during garbage collection it tried to load the workload set, it would calculate its feature band as 9.0.100 and look for the workload set under the sdk-manifests\9.0.100 folder, and fail when it couldn't be found. This meant garbage collection would always fail. For most workload commands this would be reported as a warning, but for the uninstall command it would cause the whole command to fail.

This PR fixes the issue in two ways:

  • Correctly calculate the baseline workload set feature band when creating the baseline workload set
  • When scanning for workload sets, ignore any where the feature band folder name isn't a valid feature band, or where there is an inconsistency between the feature band in the folder name and the feature band of the workload set

Correctly calculate baseline workload set feature band

The LayoutManifests target of the build was using a regex to calculate the feature band based on the workload set version. This PR changes that to use a build task that calls the same code that the product does to do the workload set version mapping. This involves:

  • Consolidating the workload set version mapping logic into a common WorkloadSetVersion class
  • Allowing nullable annotations in the dotnet project, so that the WorkloadSetVersion class could use nullability annotations (since it also is consumed by projects that have nullability enabled)
  • Switching from NuGetVersion to ReleaseVersion in the WorkloadSetVersion.FromWorkloadSetPackageVersion logic. Previously, the methods to convert in different directions where in different locations, to avoid adding a dependency on the NuGet APIs where it wasn't necessary. ReleaseVersion appears to be available in all the locations that these methods are used, so it is a better choice. However, making this change introduces risk that a difference in behavior between NuGetVersion and ReleaseVersion could cause this to be a change in the SDK behavior.
  • Creating a GetWorkloadSetFeatureBand task in core-sdk-tasks and using it in the LayoutManifests target to calculate the feature band for the baseline workload set

Ignore workload sets with invalid or mismatched feature bands when scanning for available workload sets

This is a change to SdkDirectoryWorkloadManifestProvider. When scanning for workload sets, it ignores any that it would not be able to find later based on the workload set version due to a mismatched feature band folder. This will avoid errors if the SDK later tries to load that workload set and can't find it.

However, this does somewhat reduce the diagnosibility of issues, as it will silently ignore any workload sets that are in the wrong feature band folder. The SdkDirectoryWorkloadManifestProvider doesn't currently have any way to write warnings or similar messages to a log.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Workloads untriaged Request triage from a team member labels Sep 27, 2024
@dsplaisted dsplaisted requested a review from a team September 27, 2024 01:40
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.

This is a bit confusing with nullable annotations being added and moving the workload set version <--> workload set package version logic to a new class on top of the real change (a little error catching code in SdkDirectoryWorkloadManifestProvider and making a new task to return the workload set feature band).

I'm a little unclear as to whether this is the right direction. My impression was that a preview SDK should use a preview feature band for its baseline manifest. It should find its preview baseline set (along with closely related preview baseline sets). A release 9.0.100 SDK shouldn't find the preview baseline set, as it should find its own.

In that case, the only real bug here is that GC is doing the feature band calculation wrong, which should be a smaller/easier fix anyway.

As an aside, that regex was pulled from how we calculate feature bands for some individual workloads. (Example) If you think we should be using a different feature band for the folder we put workload sets into, do we also need to update those?

@dsplaisted
Copy link
Member Author

I'm a little unclear as to whether this is the right direction. My impression was that a preview SDK should use a preview feature band for its baseline manifest. It should find its preview baseline set (along with closely related preview baseline sets). A release 9.0.100 SDK shouldn't find the preview baseline set, as it should find its own.

Preview SDKs do use preview feature bands. If you have SDK version 9.0.100-rc.1.24476.1, then its feature band is 9.0.100-rc.1. However, SDK versions with -rtm in them are treated specially. Basically when we switch to -rtm, it's not treated as preview anymore. So if you have SDK version 9.0.100-rtm.24476.1 then the feature band is just 9.0.100.

As an aside, that regex was pulled from how we calculate feature bands for some individual workloads. (Example) If you think we should be using a different feature band for the folder we put workload sets into, do we also need to update those?

Yes, we should be consistent in how we calculate feature bands, so if we can switch from MSBuild regexes to a task which calls the same code the product uses, that would be good.

@dsplaisted dsplaisted force-pushed the fix-baseline-manifest-version branch from a0cdfec to c2d4357 Compare September 30, 2024 21:07
@dsplaisted dsplaisted changed the base branch from release/9.0.1xx to release/9.0.2xx September 30, 2024 21:07

public override bool Execute()
{
WorkloadSetFeatureBand = Microsoft.DotNet.Workloads.Workload.WorkloadSetVersion.GetFeatureBand(WorkloadSetVersion).ToString();
Copy link
Member

Choose a reason for hiding this comment

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

nit: Can we capture some of this in a using statement?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

<ItemGroup>
<PackageReference Include="Microsoft.Build.Tasks.Core" />
<PackageReference Include="Microsoft.Build.Utilities.Core" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="NuGet.Versioning" />
<PackageReference Include="NuGet.Packaging" />
<PackageReference Include="System.Reflection.Metadata" VersionOverride="$(SystemReflectionMetadataLoadContextVersion)" />
<PackageReference Include="Microsoft.Deployment.DotNet.Releases" />
Copy link
Member

Choose a reason for hiding this comment

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

Will this trigger an additional module load for VS perf tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is in the core-sdk-tasks project, which is the tasks used by the .NET SDK build itself. So it won't affect the tasks that are part of the .NET SDK and get used by most developers when building projects with the .NET SDK. Those tasks (and the resolvers) which are loaded into VS already reference this package.

@@ -48,7 +49,7 @@ public static IEnumerable<object[]> WorkloadVersionsData
[MemberData(nameof(WorkloadVersionsData))]
Copy link
Member

Choose a reason for hiding this comment

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

Should we include an item in the member data for version that contain rtm since that's one of the special cases handled by SdkFeatureBand?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -11,6 +11,7 @@
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Microsoft.DotNet.MsiInstallerTests.Framework;
using Microsoft.DotNet.Workloads.Workload;
Copy link
Member

Choose a reason for hiding this comment

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

we should probably sort these usings

Copy link
Member Author

Choose a reason for hiding this comment

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

I've removed the unused usings. I think the System namespace should generally be sorted before other namespaces in the usings, so I think other than that they are sorted.

@build-analysis build-analysis bot mentioned this pull request Oct 4, 2024
@dsplaisted dsplaisted merged commit ccfae96 into dotnet:release/9.0.2xx Oct 5, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Workloads untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants