Virtual Box troubleshooting

We're using Vagrant with Oracle Virtual Box for development setup on the current project.
I get the idea and the benefits but Virtual Box is not without its quirks.

A few weeks ago after a few days vacation and powering down my machine I spent at least a day getting my environment to run again. At least one other developer has had even worse time. Vagrant has become a little bit of a pain point for some on the project. I think its pros outweight the cons but here are some useful troubleshooting tips I've learned.

Prefer to do "vagrant suspend" when moving off (mac sleep, wifi, power etc) and then do "vagrant resume" when ready to restart. A colleague even does vagrant suspend when stepping away for a coffee!

One pattern is I seem to be having issues when I switch from ethernet at work to wifi at home. 
Hitting the site in Chrome results in error "Google Chrome is having trouble accessing the network."
I understand that a change like that can change ports and the vagrant box needs to restart listening on the ports. The solution which works is:  
- run "vagrant halt" 
- then run "vagrant up"
If that does not work, try it again and reboot your workstation after the halt.

From now on when I switch I will run vagrant halt and see if that mitigates the issue.

If you ran vagrant up then always run vagrant halt before running vagrant up again

Virtual Box has a command line support and you can control vms running with command like the following:
VBoxManage list runningvms    (this will list all the vms running including their uuid)
VBoxManage controlvm <uuid>|<name> poweroff
VBoxManage unregistervm <uuid>|<name> --delete
The VBoxManage commands above can be used to kill unwanted multiple vms.

If you have to reprovision then copy your jel-vagrant folder so you have a backup copy (of config files)

Be really careful about using vagrant destroy. This will wipe the saved vm state and you will have to reinstall your instance for scratch. I found on a previous project that the vagrant scripts were out of date and I had to step through a number of errors and apply updates manually e.g. DB update of latest scripts, changes to config files etc. A real pain.


Use mac Activity Monitor to kill a process which may be holding a lock on a vm state (I had to do that once).


Restart apache in vagrant
vagrant ssh
sudo service apache2 restart




Comments

Popular posts from this blog

deep dive into Material UI TextField built by mui

angular js protractor e2e cheatsheet

react-router v6.4+ loaders, actions, forms and more