Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Conversation

@bbonaby
Copy link
Contributor

@bbonaby bbonaby commented Jul 11, 2024

Summary of the pull request

  • Adds error message when the Virtual Machine Platform Windows feature is not enabled. This is needed when attempting to install a WSL distribution for the first time. Relates to: Add reboot messaging/notifications to Dev Home for WSL installation #3400 . When wsl.exe install is ran for the first time it will install the Virtual Machine Platform feature, update wsl.exe and install the selected distribution. However, when this happens even though the distribution is installed it isn't registered until Virtual Machine Platform is enabled and the computer is rebooted. Unfortunately there is no way for us to know when both have occurred as they happen in separate processes outside of Dev Homes control, so Dev Home will just show "waiting for 's installation to complete" even though a reboot is needed.

So to fix this, we will show an error and lead the user to enable the Virtual Machine Platform feature from the Windows Customization page and reboot, before allowing them to go through the WSL environment creation flow. This should prevent a confusing experience.

Video showing what will happen now that we show the error:

wsl.install.UI.error.mp4

Also removed the verbiage surrounding adaptive cards in the error and loading progress bar in the create environment page.

References and relevant issues

I noticed that I had to use WMI to check for feature enablement again here. I'm thinking we can add a common service for WMI usage through Dev Home. See: #3381

Detailed description of the pull request / Additional comments

Validation steps performed

PR checklist

… on the machine. Fix resource string for exception in creation operation and remove mentions of adaptive cards in error message
{
if (!string.IsNullOrEmpty(_wslEnablementError))
{
_log.Error($"Virtual machine platform optional component not enabled. A reboot is needed.");
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be getting too specific. Is it worth separating out the logs into these two states.

  1. Virtual Machine Platform optional component is not enabled
  2. Virtual Machine component is enabled but the computer need to restart?

var searcher = new ManagementObjectSearcher($"SELECT InstallState FROM Win32_OptionalFeature WHERE Name = 'VirtualMachinePlatform'");
var collection = searcher.Get();

foreach (var instance in collection)
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: collection.Where(x => x != null)

/// </summary>
public ComputeSystemAdaptiveCardResult CreateAdaptiveCardSessionForDeveloperId(IDeveloperId developerId, ComputeSystemAdaptiveCardKind sessionKind)
{
if (!string.IsNullOrEmpty(_wslEnablementError))
Copy link
Contributor

Choose a reason for hiding this comment

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

I am assuming we are checking for the error message here to save on calling an expensive operation (IsVirtualMachinePlatformFeatureEnabled) every time? If yes, consider making it Lazy so it gets called once (thread safe), that way the method is more readable.

var searcher = new ManagementObjectSearcher($"SELECT InstallState FROM Win32_OptionalFeature WHERE Name = 'VirtualMachinePlatform'");
var collection = searcher.Get();

foreach (var instance in collection)
Copy link
Contributor

Choose a reason for hiding this comment

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

This foreach will always return on first iteration, is this right? Consider a FirstOrDefault() if we are interested in the first item only.

<data name="WSLInstallationFailedWithException" xml:space="preserve">
<value>Unable to install and register {0} due to error: {1}. Try using {wsl.exe} to install it manually. See {aka.ms/wslinstall}</value>
<value>Unable to install and register {0} due to error: {1}. Try using wsl.exe to install it manually. See aka.ms/wslinstall</value>
<comment>{Locked="{0}", "{1}", "{wsl.exe}", {aka.ms/wslinstall}} Text message to display when we failed to install a wsl distribution. {0} is the name of the distribution and {1} is the error message.</comment>
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing change in the comment Locked list for {wsl.exe}

Copy link
Contributor

Choose a reason for hiding this comment

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

same below

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

6 participants