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 feature bands for side-by-side manifests #33937

Merged
merged 2 commits into from
Jul 12, 2023

Conversation

dsplaisted
Copy link
Member

This PR contains two fixes:

  • Correctly report manifest feature band for side-by-side manifests in WorkloadResolver.GetInstalledManifests. Without this, various workload commands such as dotnet workload update would fail with side-by-side workload manifests, as the manifest ID would be used for the SDK feature band, and wouldn't parse correctly as a version.
  • Allow trailing commas in JSON files for workload sets

We will want to port these to 7.0.4xx (probably via #33643).

@dsplaisted dsplaisted requested review from joeloff, Forgind, MiYanni, nagilson and a team July 12, 2023 01:39
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Workloads untriaged Request triage from a team member labels Jul 12, 2023
@dsplaisted dsplaisted force-pushed the fix-manifest-feature-bands branch 2 times, most recently from 5b4d3fd to 2433fff Compare July 12, 2023 16:42
workloadManifest.Id,
workloadManifest.Version,
Path.GetDirectoryName(workloadManifest.ManifestPath)!).ManifestFeatureBand;
var workloadFeatureBand = manifestInfoDict[workloadManifest.Id].ManifestFeatureBand;
Copy link
Member

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 I understand the point of this change. It seems like it is trying to make it so you don't have to allocate a new WorkloadManifestInfo in the foreach loop...so is your goal just to move the allocations to all be before the loop?

Copy link
Member Author

Choose a reason for hiding this comment

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

Previously it was just saving the path for each manifest and then creating the WorkloadManifestInfo at the end. But now we want to keep track of the feature band together with the manifest path, so it's easier to create the WorkloadManifestInfo with the feature band information when we find each manifest.

@@ -118,9 +118,10 @@ private void LoadManifestsFromProvider(IWorkloadManifestProvider manifestProvide
using (Stream? localizationStream = readableManifest.OpenLocalizationStream())
{
var manifest = WorkloadManifestReader.ReadWorkloadManifest(readableManifest.ManifestId, manifestStream, localizationStream, readableManifest.ManifestPath);
if (!_manifests.TryAdd(readableManifest.ManifestId, manifest))
var manifestInfo = new WorkloadManifestInfo(manifest.Id, manifest.Version, readableManifest.ManifestDirectory, readableManifest.ManifestFeatureBand);
if (!_manifests.TryAdd(readableManifest.ManifestId, (manifest, manifestInfo)))
Copy link
Member

Choose a reason for hiding this comment

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

It should be very unusual for readableManifest.ManifestId to already be in _manifests, correct? That seems like an install failure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, something would be very wrong, probably a bug in the manifest provider.

@@ -71,7 +71,12 @@ public static WorkloadSet FromDictionaryForJson(IDictionary<string, string> dict
public static WorkloadSet FromJson(string json, SdkFeatureBand defaultFeatureBand)
{
#if USE_SYSTEM_TEXT_JSON
return FromDictionaryForJson(JsonSerializer.Deserialize<IDictionary<string, string>>(json)!, defaultFeatureBand);
var jsonSerializerOptions = new JsonSerializerOptions()
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if we should have a "standard" JsonSerializerOptions that we use everywhere to avoid forgetting AllowTrailingCommas. What do you think?


string manifestContents3 = """
{
"version": "12.0.1",
Copy link
Member

@joeloff joeloff Jul 12, 2023

Choose a reason for hiding this comment

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

Do we have any tests covering manifest versions that are prereleases and/or have full buildmetadata, e.g. "1.0.0-preview.1.23361.1+c291ddefb05ff3dd6a0b51df152bba794908dc64"?

Just curious, not asking we change this test now and rerun.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have various tests that cover prerelease versions. We don't have any with build metadata. Is there anything specific with build metadata you think we should be testing? I don't think we'll be using it in the versions we use for workloads.

Copy link
Member

Choose a reason for hiding this comment

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

No, if we have ones with prerelease parts then that's fine, I couldn't recall if we did.

Copy link
Member

@nagilson nagilson left a comment

Choose a reason for hiding this comment

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

Overall the changes seem good to me, I am still testing it a bit more to see if I can find anything

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.

4 participants