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

docs: add guide to setup windows machine for WSL #2876

Merged
merged 1 commit into from
Feb 7, 2024
Merged

Conversation

lucasmoura
Copy link
Contributor

Add guide to setup windows machine for running our integration tests on WSL instances

@github-actions github-actions bot added the docs label Dec 5, 2023
@lucasmoura lucasmoura force-pushed the wsl-docs branch 2 times, most recently from 68272c9 to eff6b87 Compare December 6, 2023 14:59
Copy link
Collaborator

@orndorffgrant orndorffgrant left a comment

Choose a reason for hiding this comment

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

Wow this is complicated - thank you for figuring this out!!! Just left various small comments in attempts to clarify

I think this can go straight into the docs branch since it doesn't depend on an unreleased feature of pro-client.

Should this be in RST instead of markdown?

Comment on lines 7 to 8
This how to guide will explain all the necessary steps for the setup, from launching the image
from Azure to testing if WSL is correctly working on the machine.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This how to guide will explain all the necessary steps for the setup, from launching the image
from Azure to testing if WSL is correctly working on the machine.
This how-to guide will explain all the necessary steps for the setup, from launching the image
in Azure to testing if WSL is correctly working on the machine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also specify the version of windows this is intended to be run on?

Copy link
Contributor

Choose a reason for hiding this comment

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

The from/in issue is a bit ambiguous. The former implies that it's an Azure image, the latter implies it could be an Ubuntu image which we're launching in Azure. I think we intend the second case, based on the below sections, but I want to double check my understanding is correct here.

Choose a reason for hiding this comment

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

I guess this is a matter of taste, but wouldn' tit read better if we drop the how-to part of the sentence : This how-to guide will explain all the necessary step.... Also not being an explanation, but rather a how-to guide, shouldn't we rephrase that sentence into This guide presents all the necessary steps... ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is the latter. We are launching a Windows machine in Azure. And I will also specify the Windows version here as well

integration tests.

After that, select the `Windows 11` image and mark the `Security Type` as *Standard*.
![windows_secuirty_type](windows-security-type.png)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
![windows_secuirty_type](windows-security-type.png)
![windows_security_type](windows-security-type.png)

Copy link
Contributor

Choose a reason for hiding this comment

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

The text in the square brackets is usually displayed as alt text. We should either change this to something more descriptive, or leave it blank.

Do we need to provide any guidance on image selection?

Choose a reason for hiding this comment

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

I'd add the following to this step:

The alternative "Trusted Launch" [doesn't support Nested Virtualization](https://learn.microsoft.com/en-us/azure/virtual-machines/trusted-launch#unsupported-features), required to run WSL.

or something similar.

Although this is not an explanation documentation, if the user skips this step it can be really hard to figure out what is causing the error when trying to set up a WSL instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, I will leave it blank

Now, install a Bionic instance to test the whole WSL setup is working as expected:

```console
$ winget install --id "9PNKSF5ZN4SW" --accept-source-agreements --accept-package-agreements --silent
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm guessing this ID refers to the bionic wsl app? I think that deserves a short explanation and maybe also an explanation of how you got this ID

Choose a reason for hiding this comment

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

Note that winget install --name "Ubuntu 18.04 LTS" --exact ... would also work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a great suggestion for this guide. I will use it. Thanks @EduardGomezEscandell

dev-docs/howtoguides/pro-dashboard-service-toggles.png Outdated Show resolved Hide resolved
Copy link

@EduardGomezEscandell EduardGomezEscandell left a comment

Choose a reason for hiding this comment

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

Looks good on the WSL side.

Note that our team does not Bastion nor SSH for this so I cannot comment on that part :)

Now, install a Bionic instance to test the whole WSL setup is working as expected:

```console
$ winget install --id "9PNKSF5ZN4SW" --accept-source-agreements --accept-package-agreements --silent

Choose a reason for hiding this comment

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

Note that winget install --name "Ubuntu 18.04 LTS" --exact ... would also work.

Copy link
Contributor

@s-makin s-makin left a comment

Choose a reason for hiding this comment

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

Just some small nits and suggestions

When launching the Windows instance on Azure, there a few configurations that need to be performed,
otherwise we will not be able to launch WSL instances.

First of all, name the machine as `wsl-test`. Currently, this is the name we expect on the
Copy link
Contributor

Choose a reason for hiding this comment

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

How/where do we do this? Or can we assume this is something people already know how to do?

Copy link
Contributor

Choose a reason for hiding this comment

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

(Do we have a link to a guide that covers all this? If so, we can drop that in as a prerequisite step if it's out of scope for this article)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think there is a specif link to launch a Windows machine, but this is one the first steps when launching a image in Azure, that's why I have not added any screenshots here. But I don't have a strong opinion. If you believe it is worth, I can add it. No problem at all

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case, I think it could be helpful to link to a guide on launching images in Azure if you know of a good one. It would be ++convenient for a reader who may not have used Azure before if we can cut out a bit of Googling for them, but it's not essential.

dev-docs/howtoguides/pro-dashboard-service-toggles.png Outdated Show resolved Hide resolved
Copy link

@CarlosNihelton CarlosNihelton left a comment

Choose a reason for hiding this comment

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

Very good stuff! I only have minor comments, except for the Virtual Machine Platform one that deserves a double-check.

Comment on lines 7 to 8
This how to guide will explain all the necessary steps for the setup, from launching the image
from Azure to testing if WSL is correctly working on the machine.

Choose a reason for hiding this comment

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

I guess this is a matter of taste, but wouldn' tit read better if we drop the how-to part of the sentence : This how-to guide will explain all the necessary step.... Also not being an explanation, but rather a how-to guide, shouldn't we rephrase that sentence into This guide presents all the necessary steps... ?

integration tests.

After that, select the `Windows 11` image and mark the `Security Type` as *Standard*.
![windows_secuirty_type](windows-security-type.png)

Choose a reason for hiding this comment

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

I'd add the following to this step:

The alternative "Trusted Launch" [doesn't support Nested Virtualization](https://learn.microsoft.com/en-us/azure/virtual-machines/trusted-launch#unsupported-features), required to run WSL.

or something similar.

Although this is not an explanation documentation, if the user skips this step it can be really hard to figure out what is causing the error when trying to set up a WSL instance.

After that, just test to see if we can run commands on the WSL instance:

```console
$ wsl -d Ubuntu-18.04 --exec lsb_release -a

Choose a reason for hiding this comment

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

Note that running ubuntu1804.exe run instead of wsl -d Ubuntu-18.04 --exec is equally valid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is totally fair. I am using wsl here just because this is what I am doing on the integration tests

## Running the integration test

After this setup, you should be able to use that machine to run the WSL tests automatically.
Before running a WSL test, remember to set the following environment variables:

Choose a reason for hiding this comment

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

Set the environment variables inside each WSL instance subject to the integration tests or in the Windows host environment as well?

I suspect it's only the first, but wouldn't it be better to clarify it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is actually neither of the options, we need to set up that up on your local machine. Our integration tests will use them to start and communicate with the Windows host machine and launch the WSL tests.

But I will make this more explicit

## Configuring Hyper-V

After login into the machine through Bastion, you need to configure Hyper-V by following
this [tutorial](https://learn.microsoft.com/en-us/azure/lab-services/how-to-enable-nested-virtualization-template-vm-using-script?tabs=powershell)

Choose a reason for hiding this comment

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

I'm missing a reference to the Virtual Machine Platform optional feature. Does this step cover it?

We had this error when setting up a VM, fixed by setting that feature ON, if you remember:

WslRegisterDistribution failed with error: 0x80070424
Error: 0x80070424 The specified service does not exist as an installed service.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I have found is that when just running wsl --install, it already covers this step automatically.
But I will let @orndorffgrant and @renanrodrigo try this out first just to guarantee if this is indeed correct

Choose a reason for hiding this comment

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

According to the Microsoft Docs, --install does it for you. https://learn.microsoft.com/en-us/windows/wsl/install#install-wsl-command.

@CarlosNihelton and I are just not used to these new conveniences 😅.

Choose a reason for hiding this comment

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

Indeed 😄

@lucasmoura lucasmoura force-pushed the wsl-docs branch 3 times, most recently from 34bc2e9 to c84b446 Compare December 13, 2023 17:35
@lucasmoura
Copy link
Contributor Author

Thank you all for the review. I have updated the docs with all the suggestions made here

To install it on the machine, follow this [tutorial](https://winget.pro/winget-install-powershell/)

```
if you see the following error during installation, restart the machine first:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if you see the following error during installation, restart the machine first:
If you see the following error during installation, restart the machine first:


To install it on the machine, follow this [tutorial](https://winget.pro/winget-install-powershell/)

```
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
```
```{note}



```{note}
We are installing the pre-release version because it allow us to directly run wsl commands
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
We are installing the pre-release version because it allow us to directly run wsl commands
We are installing the pre-release version because it allow us to directly run WSL commands


To install OpenSSH server, follow these steps:

1) Open *Settings*
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I might have overlooked something, but what application are we using here?


To do that, follow these steps:

1) Create a public key to be used in the Windows machine (You can also reuse an existing key if you want to)
Copy link
Contributor

@s-makin s-makin Jan 2, 2024

Choose a reason for hiding this comment

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

Suggested change
1) Create a public key to be used in the Windows machine (You can also reuse an existing key if you want to)
1) Create a public key to be used in the Windows machine (you can also reuse an existing key if you want to).

$ icacls administrators_authorized_keys /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F"
```

Now test SSH into the machine using your private key
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Now test SSH into the machine using your private key
Now test SSH into the machine using your private key.

Copy link
Member

Choose a reason for hiding this comment

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

Please mention that the private key here should not be password protected.
I tried reusing a key which had a password, and could not run the tests because pycloudlib would need the password for the key, and I could not pass it in any way. I am not even sure pycloudlib supports this?
Anyway, generating a passwordless key works.

* **UACLIENT_BEHAVE_WSL_PRIVKEY_PATH**
* **UACLIENT_BEHAVE_WSL_PUBKEY_PATH**

Note that this variables must be set on our local machine. The integration test setup will use them
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Note that this variables must be set on our local machine. The integration test setup will use them
Note that these variables must be set on your local machine. The integration test setup will use them

* **UACLIENT_BEHAVE_WSL_PUBKEY_PATH**

Note that this variables must be set on our local machine. The integration test setup will use them
to stablish the connection with the Windows host machine to create the WSL instances the tests will
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
to stablish the connection with the Windows host machine to create the WSL instances the tests will
to establish the connection with the Windows host machine, to then create the WSL instances the tests will

Copy link
Contributor

@s-makin s-makin left a comment

Choose a reason for hiding this comment

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

Just a few nits from me, otherwise looks good :)

Comment on lines +18 to +19
After that, select the `Windows 11` image and mark the `Security Type` as *Standard*.
![](windows-security-type.png)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The screenshow shows Ubuntu not windows.
Also I see several Windows 11s

  • Windows 11 Pro
  • Windows 11 Pro N
  • Windows 11 Enterprise
  • Windows 11 Enterprise multi-session
  • Windows 11 Enterprise N

I'll try out the Windows 11 Pro for now but it would be good to choose a specific one for the guide

@lucasmoura lucasmoura force-pushed the wsl-docs branch 2 times, most recently from 6763717 to 95323b9 Compare January 16, 2024 20:29
@lucasmoura lucasmoura marked this pull request as ready for review January 16, 2024 20:30
@lucasmoura
Copy link
Contributor Author

@orndorffgrant I have fixed the issues you mentioned while also adding a paragraph about the license checkbox

To install OpenSSH server, follow these steps:

1) Open *Settings*
2) Go to *Apps*
Copy link
Collaborator

Choose a reason for hiding this comment

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

For me, Optional Features is in the "System" category, not the "Apps" category

Copy link
Member

Choose a reason for hiding this comment

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

This is correct - I found it in Sysytem

2) Send the public key to the Windows machine:

```console
$ scp PUB_KEY_PATH ubuntu@$UACLIENT_BEHAVE_WSL_IP_ADDRESS:%programdata%/ssh
Copy link
Collaborator

Choose a reason for hiding this comment

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

This didn't work for me but the following did

scp .ssh/wsl_test_rsa.pub ubuntu@$UACLIENT_BEHAVE_WSL_IP_ADDRESS:C:\\ProgramData\\ssh

Copy link
Member

Choose a reason for hiding this comment

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

both work for me

Copy link
Contributor Author

@lucasmoura lucasmoura Jan 26, 2024

Choose a reason for hiding this comment

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

I am changing to the option that works for everyone

Add guide to setup windows machine for running our
integration tests on WSL instances
@lucasmoura
Copy link
Contributor Author

@orndorffgrant @renanrodrigo updated

@lucasmoura lucasmoura merged commit 043550b into docs-devel Feb 7, 2024
7 checks passed
@lucasmoura lucasmoura deleted the wsl-docs branch February 7, 2024 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants