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

Enabling reward_wsl2_direct_mount in .reward.yml file slows down installation and every container operation #1

Closed
adexandros opened this issue Mar 5, 2021 · 9 comments

Comments

@adexandros
Copy link

Tested this on WIndows 10 with WSL2 installed, Ubuntu 20.04:

I have uncommented the flag reward_wsl2_direct_mount in the ~/.rewardw.yml file to leverage WSL2, however after setting up a env and running reward bootstrap, the whole installation process takes about ~50m, vs ~4m of normal installation without direct mount.
Also after using reward shell and any command inside the container, even just bin/magento are super slow, as well as the site page load, while it works perfectly with a Mutagen installation.
Moreover when exiting from a container with exit it produce the following error:

/var/www/html$ exit
exit
Error: exit status 130
Usage:
  reward shell [command] [flags]

Flags:
      --container string   the container you want to get in (default "php-fpm")
  -h, --help               help for shell

Global Flags:
      --app-dir string       app home directory (default "C:\\Users\\micro\\.reward")
  -c, --config string        config file (default "C:\\Users\\micro\\.reward.yml")
      --debug                enable debug mode (same as --log-level=debug)
      --disable-colors       disable colors in output
      --docker-host string   docker host (default "npipe:////./pipe/docker_engine")
      --log-level string     logging level (options: trace, debug, info, warning, error) (default "info")
      --wsl2-direct-mount    use direct mount in WSL2 instead of syncing

INFO[2021-03-05T10:18:44Z] exit status 130

I am not sure why this happens, just noticed while testing multiple site installations

@janosmiko
Copy link
Contributor

Hello @adexandros, thank you for opening the first issue! 🎂

Please make sure if you are using Reward with WSL2 then your working directory have to be inside your WSL2 partition.

Also, could you run the following command and send me its output?

DEBUG=true reward shell

@janosmiko
Copy link
Contributor

janosmiko commented Mar 5, 2021

@adexandros on your second question. If you exit reward's shell without explicitly defining the exit code the previous command's exit code will be passed.

Example:
If you call /bin/true, that commands exit code will 1. If you exit after running it, bash will pass this exit code as it's own and that will be caught by reward.

reward shell
www-data@m2-php-fpm:/var/www/html$ /bin/false
www-data@m2-php-fpm:/var/www/html$ echo $?
1
www-data@m2-php-fpm:/var/www/html$ /bin/false
www-data@m2-php-fpm:/var/www/html$ exit
exit
Error: exit status 1
Usage:
  reward shell [command] [flags]

Flags:
      --container string   the container you want to get in (default "php-fpm")
  -h, --help               help for shell

Global Flags:
      --app-dir string       app home directory (default "/Users/mixe3y/.reward")
  -c, --config string        config file (default "/Users/mixe3y/.reward.yml")
      --debug                enable debug mode (same as --log-level=debug)
      --disable-colors       disable colors in output
      --docker-host string   docker host (default "unix:///var/run/docker.sock")
      --log-level string     logging level (options: trace, debug, info, warning, error) (default "info")

INFO[2021-03-05T14:31:04+01:00] exit status 1

This behaviour is coming from the underlying architecture (docker-compose and even bash). You can find this in exit command's help.

www-data@m2-php-fpm:/var/www/html$ exit --help
exit: exit [n]
    Exit the shell.

    Exits the shell with a status of N.  If N is omitted, the exit status
    is that of the last command executed.

@adexandros
Copy link
Author

adexandros commented Mar 5, 2021

Hi @janosmiko , where do you want me to type that command exactly?
If I type in my powershell I am getting:

INFO[2021-03-05T10:18:44Z] exit status 130
PS C:\Projects\magento-test> DEBUG=true reward shell
DEBUG=true : The term 'DEBUG=true' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At line:1 char:1
+ DEBUG=true reward shell
+ ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (DEBUG=true:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Also what do you mean exactly with:

Please make sure if you are using Reward with WSL2 then your working directory have to be inside your WSL2 partition

the path to my Projects folder from inside my Ubuntu would be: /mnt/c/Users/micro/Projects ; I cannot create a new project with reward directly inside since the reward command is not recognized by Ubuntu in this instance.

I am still new to WSL2 so it's very likely I am doing something wrong

@janosmiko
Copy link
Contributor

Thanks for your reply, @adexandros !

The command with the DEBUG=true environment variable have to be run in you Ubuntu shell.

I'm not sure where you installed Reward but if its something like C:\bin, then append the following line to your .bashrc in Ubuntu:
export PATH=$PATH:/mnt/c/bin
And reload your bash (or just run this command: source ~/.bashrc).
With this you will be able to reach reward (as reward.exe) from your Ubuntu.


And lastly, if your Project is directly on your Windows drive (like C:\Users\micro\Project is), then it's not "compatible" with WSL2. (In this case it's just mounted to WSL2)
If you open an Ubuntu WSL2 terminal, that will be on a filesystem which is inside your Ubuntu Virtual Machine. And the folders under /mnt are the Windows partitions mounted back to your WSL2 System (so in this case Ubuntu mounts your Windows drives).

So to use WSL2, you will have to clone your project directly inside Ubuntu WSL2 terminal to for example /home/micro/Projects.

For more information about how WSL2 works you can see the first section here and I suggest to check the 2 links there:
https://rewardenv.readthedocs.io/en/latest/configuration/wsl2.html#wsl-and-wsl2-support

@adexandros
Copy link
Author

Hi @janosmiko , so I did the following:

  • Logged into my Ubuntu instance
  • added export PATH=$PATH:/mnt/c/bin to my ~/.bashrc
  • also added alias reward=reward.exe because otherwise I wouldn't be able to actually execute it
  • created in my linux instance a new folder in /home/micro/projects/wsltest
  • cd into directory
  • run reward env-init wsltest
  • run reward bootstrap

Getting this error now:

wsltest_elasticsearch_1 is up-to-date
Creating wsltest_php-fpm_1 ... error

ERROR: for wsltest_php-fpm_1  Cannot create container for service php-fpm: failed with: can't access specified distro mount service: stat /run/guest-services/distro-services/ubuntu-20.04.sock: no such file or directory

ERROR: for php-fpm  Cannot create container for service php-fpm: failed with: can't access specified distro mount service: stat /run/guest-services/distro-services/ubuntu-20.04.sock: no such file or directory
ERROR: Encountered errors while bringing up the project.
Error: exit status 1

@janosmiko
Copy link
Contributor

Could you check if you enabled WSL2 Integration in Docker settings?
You can find a documentation about this here (see the "if you encounter the following error section"):
https://rewardenv.readthedocs.io/en/latest/configuration/wsl2.html

Related issue:
docker/for-win#5096

@adexandros
Copy link
Author

I just noticed that that's one of the know issue in the documentation

@adexandros
Copy link
Author

@janosmiko so I had the WSL2 integration enabled already but I specifically needed to select my instance of Ubuntu even though was the only and default one;
That resolved the issue, installation completed in about ~4m, like the other initial tests I made, so all good here, thanks for the help; I'll keep experimenting

@janosmiko
Copy link
Contributor

I'm glad to hear that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants