dergachev/vagrant-vbox-snapshot

Run `vagrant reload` when restoring snapshots with changed config

fgrehm opened this issue · 7 comments

Hey @dergachev, tks for the awesome plugin, it's the first one that actually worked for me :-)

I just had to restore a snapshot and ended up finding out that shared folders stopped working after a vagrant snapshot go .... Having a quick look on the codebase I found that the plugin brings up the VM back after restoring it running VirtualBox commands by hand

Right now I can work around it by running vagrant reload, but it would be nice if the plugin handled that automatically ;)

WDYT?

@fgrehm,

Running "vagrant reload" (or the equivalent) automatically is out of the question, since it takes so darn long!

But it's important to warn people about the fact that restoring can bring your system out of whack with the Vagrantfile config, so I took a stab at that.

To appease you, I also added a "--reload" flag, which does what you'd expect.

So far I did all this only in the "go" subcommand, since I'm thinking of merging "go" and "back" commands altogether. (Please feel free to weigh in your thoughts on that in #3)

Here's a screenshot of the warning message:

By the way, I added instructions on how to start hacking on vagrant-vbox-snapshot here:
https://github.com/dergachev/vagrant-vbox-snapshot#development

In order to test the changes in your environment, do the following:

git clone https://github.com/dergachev/vagrant-vbox-snapshot.git
cd vagrant-vbox-snapshot

vim Vagrantfile                         # config.vm.synced_folder "/tmp", "/tmp/STATE1"
vagrant up
vagrant ssh -- 'ls /tmp/STATE1'         # ensure the newly synced folder exists on the VM
vagrant snapshot take STATE1

vim Vagrantfile                         # config.vm.synced_folder "/tmp", "/tmp/STATE2"
vagrant reload
vagrant ssh -- 'ls /tmp/STATE2'         # ensure the newly synced folder exists on the VM
vagrant snapshot take STATE2

vagrant snapshot go STATE1              # warning message about shared folders changing
vagrant snapshot go STATE1              # no warning, since shared folders haven't changed
vagrant snapshot go STATE2              # warning, since shared folder state has changed
vagrant snapshot go STATE1 --reload     # no warning, but because we do a reload instead of start

Before closing this issue, the following need to get done:

  • merge these changes to "snapshot back" subcommand (see #2)
  • update README.md with new API
  • cut a new gem

@dergachev awesome! I'm heading out now but will give a shot at it tonight. tks a lot :)

👍 I've just tested and everything seems to be working just fine, I've installed the plugin from sources and I'll report back in case I hit any problem. tks for working on it :)

NOTE TO SELF:

Just ran into a very related problem: when you change your memory allocation (via Vagrantfile) and then restore, you are reverted to the old setting and need to run vagrant reload again. I'd really be happier if the check I implemented was flexible enough to detect if ANY meaningful setting had changed, and suggest a reload.

I've also really gotta roll that release....

Finally!! Released in v0.0.3