Score:0

WSL2 - snap installation of microstack fails

cv flag

I am running Ubuntu 22.04.2 LTS on Windows 11 with WSL2.

init microstack init fails at "Configuring networking" with "snapctl start microstack.ovs-vswitchd --enable' returned non-zero exit status 1"

I installed microstack successfully with sudo snap install microstack --devmode --edge

I also previously tried with snap install microstack --classic --beta and again with snap install microstack --beta

In all examples the sudo microstack init --auto --control fails with:

2023-03-19 14:05:07,415 - microstack_init - INFO - Configuring clustering ...
2023-03-19 14:05:07,568 - microstack_init - INFO - Setting up as a control node.
2023-03-19 14:05:13,275 - microstack_init - INFO - Generating TLS Certificate and Key
2023-03-19 14:05:14,800 - microstack_init - INFO - Configuring networking ...
Traceback (most recent call last):
  File "/snap/microstack/245/bin/microstack", line 11, in <module>
    load_entry_point('microstack==0.0.1', 'console_scripts', 'microstack')()
  File "/snap/microstack/245/lib/python3.8/site-packages/microstack/main.py", line 44, in main
    cmd()
  File "/snap/microstack/245/lib/python3.8/site-packages/init/main.py", line 60, in wrapper
    return func(*args, **kwargs)
  File "/snap/microstack/245/lib/python3.8/site-packages/init/main.py", line 228, in init
    question.ask()
  File "/snap/microstack/245/lib/python3.8/site-packages/init/questions/question.py", line 210, in ask
    self.yes(awr)
  File "/snap/microstack/245/lib/python3.8/site-packages/init/questions/__init__.py", line 208, in yes
    enable('ovs-vswitchd')
  File "/snap/microstack/245/lib/python3.8/site-packages/init/shell.py", line 162, in enable
    check('snapctl', 'start', 'microstack.{}'.format(service), '--enable')
  File "/snap/microstack/245/lib/python3.8/site-packages/init/shell.py", line 69, in check
    raise subprocess.CalledProcessError(proc.returncode, " ".join(args))
subprocess.CalledProcessError: Command 'snapctl start microstack.ovs-vswitchd --enable' returned non-zero exit status 1.
Score:0
lu flag

Sorry if I reply a little late, it is not possible to install Microstack DIRECTLY on WSL2, it can be done but the procedure is a bit complicated but in the end it works!

This doesn't work because the default Microsoft kernel for WSL2 doesn't include Openvswitch, and so there is a service that doesn't start and fails all initialization to fix this you need a custom kernel on your WSL2 distribution with openvswitch included

I'll explain all the procedure you have to do. First of all i used this method on ubuntu 22.04 but i think it will work on 20.04 too, but i'm not sure

First of all if you already have an Ubuntu 22.04 distro or don't have one, you should install it with:

wsl --install -d Ubuntu-22.04

if in case you already have it, I suggest you reset the distro with

wsl --unregister Ubuntu-22.04

After you have a completely clean Ubuntu 22.04 distro, you can start following the next steps Now you need to install everything needed to compile your custom kernel

sudo apt update -y
sudo apt install -y build-essential flex bison libssl-dev libelf-dev libncurses-dev autoconf libudev-dev libtool

after you have installed these necessary packages, enter the /usr/src folder with

cd /usr/src

Now you need to clone the kernel source repository:

sudo git clone https://github.com/microsoft/WSL2-Linux-Kernel.git --depth=1 wsl2

If in case the repository is not cloned with this error:

Error: "fatal: unable to access 'https://github.com/microsoft/WSL2-Linux-Kernel.git': Could not resolve host: github.com"

Use these two commands:

git config --global --unset http.proxy
git config --global --unset https.proxy

Once you've managed to clone the kernel repository, you can proceed

go into the "wsl2" folder

cd wsl2

Now you'll need to do some minor configuration before compiling the actual kernel

log in as root

sudo su
zcat /proc/config.gz > .config

Open the configuration for the kernel:

make menuconfig

And enable these entries: to select press the Y key

General Setup\Compile the kernel with warnings as errors
General Setup\Automatically append version information to the version string

And then the entry for Openvswitch this time to select use the M key

Networking Support\Networking Options\Open vSwitch

Then exit and save the settings

Now you need to edit a file stored in "Microsoft\config-wsl"

nano Microsoft/config-wsl

Now we need to change the kernel name:

and now go change the CONFIG_LOCALVERSION directive with the value of "-WSL2-Custom-Kernel-ovs"

CONFIG_LOCALVERSION="-WSL2-Custom-Kernel-ovs"

now go uncomment the line CONFIG_OPENVSWITCH, and assign "y" This is a very important thing the CONFIG_OPENVSWITCH item is commented out

CONFIG_OPENVSWITCH=y

Now save this last file and install these two packages:

apt install -y bc dwarves

you are now ready to build your custom kernel

To start building the kernel run:

make O=out KCONFIG_CONFIG=Microsoft/config-wsl

if in case you immediately get an error running the kernel build run this:

make mrproper

if he asks you something about Openvswitch, answer (yes)

and now you will have to wait a lot of time, the compilation should take more than two hours, this depends on your computer's timing, it took me almost 4 hours

When the compilation was successful

enter the "out" folder

cd out

then in your user folder C:\Users\username\ create a folder "wsl2"

From wsl copy this file to the folder created earlier:

cp vmlinux /mnt/c/Users/username/wsl2/

then run the command

make modules_install

Then in your user folder create a file named ".wslconfig"

Open with notepad and specify the location of the exported kernel

[wsl2]
kernel = C:\\Users\\username\\wsl2\\vmlinux

save this file

now you need to restart your WSL2 distro

wsl --shutdown

now open the WSL2 distro again, if by typing the command:

sudo uname -r

and you get to see this:

version-WSL2-Custom-Kernel-ovs+

You have perfectly installed and configured the custom kernel on your WSL2 and now you can finally run Microstack!

The process is a long and complicated one but if you managed to get here you are ready to install Microstack

install Microstack:

sudo snap install microstack --devmode --edge

Initialize microstack with:

sudo microstack init --auto --control

And if you did everything correctly that error will be fixed!

when the initialization is successful, you will be able to access the openstack dashboard with the address of your WSL2 distro

https://wsl2ipaddress/

And to get the administrator password to access the dashboard, type

sudo snap get microstack config.credentials.keystone-password

that's all, now you can enjoy a working installation of Microstack inside WSL2!

Update the Answer

If you don't want to do all the operations listed above

I created and published on GitHub two scripts in SH that simplify all the operations

The script is in two versions:

This is the version that compiles the kernel: (It will take 2-4 hours) https://github.com/Sorecchione07435/Microstack-Configurer-WSL2

While this version will use a vmlinux file already exported with all kernel modules as well (It will take 1-2 minutes)

https://github.com/Sorecchione07435/Microstack-Configurer-WSL2-v2

After successfully running one of the two scripts, you will already be able to install and initialize Microstack as the bulk has already been done by the script

Everything is explained on the GitHub pages

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.