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

Plugin does not work w/ Vagrant >= 1.1.x #2

Closed
kiesel opened this issue May 13, 2013 · 25 comments
Closed

Plugin does not work w/ Vagrant >= 1.1.x #2

kiesel opened this issue May 13, 2013 · 25 comments

Comments

@kiesel
Copy link

kiesel commented May 13, 2013

The following error can be found in the logs:

 INFO vagrant: `vagrant` invoked: ["up"]
 INFO environment: Environment initialized (#<Vagrant::Environment:0x25d8860>)
 INFO environment:   - cwd: C:/cw/home/kiesel/dev/bit_config/svc/config/development
 INFO environment: Home path: C:/Users/kiesel/.vagrant.d
 INFO environment: Local data path: C:/cw/home/kiesel/dev/bit_config/svc/config/development/.vagrant
 INFO environment: Loading plugin from JSON: vagrant-persistent-storage
ERROR root: Failed to load plugin: vagrant-persistent-storage
ERROR root:  -- Error: #<NameError: uninitialized constant Vagrant::Config::Base>
ERROR root:  -- Backtrace:
ERROR root: C:/Users/kiesel/.vagrant.d/gems/gems/vagrant-persistent-storage-0.0.2/lib/vagrant-persistent-storage/config.rb:2:in `<module:VagrantPersistentStorage>'
C:/Users/kiesel/.vagrant.d/gems/gems/vagrant-persistent-storage-0.0.2/lib/vagrant-persistent-storage/config.rb:1:in `<top (required)>'
C:/vagrant/Vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
C:/vagrant/Vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
C:/Users/kiesel/.vagrant.d/gems/gems/vagrant-persistent-storage-0.0.2/lib/vagrant-persistent-storage.rb:3:in `<top (required)>'
C:/vagrant/Vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
C:/vagrant/Vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
C:/vagrant/Vagrant/embedded/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
C:/vagrant/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant.rb:186:in `require_plugin'
C:/vagrant/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/environment.rb:768:in `block in load_plugins'
C:/vagrant/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/environment.rb:765:in `each'
C:/vagrant/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/environment.rb:765:in `load_plugins'
C:/vagrant/Vagrant/embedded/gems/gems/vagrant-1.2.2/lib/vagrant/environment.rb:132:in `initialize'
C:/vagrant/Vagrant/embedded/gems/gems/vagrant-1.2.2/bin/vagrant:62:in `new'
C:/vagrant/Vagrant/embedded/gems/gems/vagrant-1.2.2/bin/vagrant:62:in `<top (required)>'
C:/vagrant/Vagrant/bin//../embedded/../embedded/gems/bin/vagrant:23:in `load'
C:/vagrant/Vagrant/bin//../embedded/../embedded/gems/bin/vagrant:23:in `<main>'
 INFO interface: error: Failed to load the "vagrant-persistent-storage" plugin. View logs for more details.

Failed to load the "vagrant-persistent-storage" plugin. View logs for more details.
@thasmo
Copy link

thasmo commented May 20, 2013

Sounds like a pretty cool plugin! Any plans on making it compatible to Vagrant 1.2?

@kusnier
Copy link
Owner

kusnier commented Jun 14, 2013

I'll see what I can do.

@zh4ngx
Copy link

zh4ngx commented Jun 18, 2013

I think this involves making it compatible with embedded ruby project, rights?

@madAndroid
Copy link
Contributor

I have a (mostly) working modification of this working under vagrant 1.2.3 - in my fork .. it could do with some testing before I submit a pull request. Would anyone like to help with some testing?

@thasmo
Copy link

thasmo commented Aug 22, 2013

Hi there - does it also work using the latest Vagrant version? I'd like to test it, but I'm always on the latest Vagrant version.

@madAndroid
Copy link
Contributor

Not sure, to be honest ... I could upgrade and test it on the latest, but I'm a little reluctant to, since I've got a few other plugins installed that are quite critical to my work, and I don't want to suddenly be unable to use those..

I guess you could try and see? I've been testing by symlinking my checkout to ~/.vagrant.d/gems/gems/vagrant-persistent-storage-0.0.2

It works on 1.2.3, so I'm assuming it will work on 1.2.7 (latest now, apparently)

@madAndroid
Copy link
Contributor

Caveats: it's currently dependent on the VirtualoBox provider, and has hooks that are particular to VBox... this should be fairly straightforward to get working for VMWare fusion, but I've not got that installed to test it.. and it means that the hooks will need to be made provider agnostic/independent.

@thasmo
Copy link

thasmo commented Aug 22, 2013

I'm on Windows but if you tell me how to install the gem I can test the plugin on the currect Vagrant version.

@madAndroid
Copy link
Contributor

you should be able to install it using the vagrant commandline switch:

vagrant plugin install vagrant-persistent-storage

this will install the version that's incompatible with the latest vagrant, but you can then remove the plugin and replace it from one cloned from my fork.

I've not used vagrant or even ruby/gem on Windows before, so I'm a little in the dark about where the plugins are installed etc ... but in order to test the changes I've put in, you'll need to clone from git@github.com:madAndroid/vagrant-persistent-storage.git and then overwrite the original plugin install with the contents of that checkout/clone ... good luck! let me know how you get on.. really interested to see how this works on vagrant on Windows

@thasmo
Copy link

thasmo commented Aug 22, 2013

Okay, I'll have a look soon - just playing around with some packer building. :)

@madAndroid
Copy link
Contributor

hi @kusnier, would you be willing to accept a pull request to implement the vagrant > 1.1.x plugin compatibility?

@kusnier
Copy link
Owner

kusnier commented Sep 3, 2013

Yes. I will check first if the changes are working.

@madAndroid
Copy link
Contributor

great stuff :) cheers!

@kusnier
Copy link
Owner

kusnier commented Sep 4, 2013

I have tested your changes but something is not working right. The drive is not created and attached.

How i tested:

Created a checkout of your fork.

echo "require 'rubygems'
require 'bundler/setup'
Bundler::GemHelper.install_tasks
" > Rakefile

Fix Version in gemspec:
gem.version = VagrantPlugins::PersistentStorage::VERSION

Remove old vagrant dependency
gem.add_dependency 'vagrant'

Create and install the gem:

bundle install
rake build
vagrant plugin install pkg/vagrant-persistent-storage-0.0.3.gem

Now create a new vagrant box:

Add following to the Vagrantfile

config.persistent_storage.location = "/Users/kuse/testvps/vmtest/testhdd.vdi"
config.persistent_storage.size = 5000
config.persistent_storage.mountname = 'mysql'
config.persistent_storage.filesystem = 'ext4'
config.persistent_storage.mountpoint = '/var/lib/mysql'
config.persistent_storage.volgroupname = 'myvolgroup'

vagrant up
vagrant destroy

The log files can be found on gist: https://gist.github.com/kusnier/6434718

I have used a Mac (10.8.4) for my tests.

@madAndroid
Copy link
Contributor

ah, will need to update the README.md .. I had recently added an 'enabled' switch, here: https://github.com/madAndroid/vagrant-persistent-storage/blob/master/lib/vagrant-persistent-storage/config.rb#L35

can you add that to your config and try again?

config.persistent_storage.enabled = 'true'

perhaps that could be omitted and made implicit on the presence of the other config keys

@madAndroid
Copy link
Contributor

also, just tried with your config .. you'll need to ensure the storage size is quoted: "5000"

@madAndroid
Copy link
Contributor

looks like it's going to need more work ..
most recent testing shows that volume is overwritten whether create is set to true or false ..
I'm not sure why that's happening now, pretty sure it was working before :)

I'll make some more changes when I get the chance, and ensure it's working properly..
it's my first go at ruby, bound to be a few bumps along the way :D

@kusnier
Copy link
Owner

kusnier commented Sep 4, 2013

With config.persistent_storage.enabled = 'true' the drive is now created. But this is done with every vagrant up.

I found a other problem. When you do a vagrant destroy a error is thrown.

$ vagrant status
Current machine states:

default                   running (virtualbox)

$ vagrant destroy
[default] ** Detaching persistent storage **
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["storageattach", "36f214d0-d192-44e3-a212-b964a781b567", "--storagectl", "SATA Controller", "--port", "1", "--device", "0", "--type", "hdd", "--medium", "none"]

Stderr: VBoxManage: error: Could not unmount the currently mounted media/drive (VERR_INTERNAL_ERROR)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component Console, interface IConsole, callee nsISupports
VBoxManage: error: Context: "DetachDevice(Bstr(pszCtl).raw(), port, device)" at line 381 of file VBoxManageStorageController.cpp

@madAndroid
Copy link
Contributor

Okay, I've made some changes to address the disk being overwritten, it wasn't being created each time, but the scripts which format the disk were overwriting it, as far as I can tell. This was working okay on centos, but not on ubuntu - I've confirmed that it's working on ubuntu now.

The issue with destroy: I wasn't experiencing that, I'm using Ubuntu; not sure if the hot swap capabilities of virtualbox are different between OSx and Linux. I'm assuming that;s the reason you were seeing that, but my testing didn't bring that up... I've adjusted the hooks here:
https://github.com/madAndroid/vagrant-persistent-storage/blob/e88325eb1f6e5c722cdc01607e176332e954a772/lib/vagrant-persistent-storage/plugin.rb#L42-L47,
which should hopefully resolve that

could you please update from my fork again, and retest? thanks :)

@kusnier
Copy link
Owner

kusnier commented Sep 4, 2013

The drive is not accessible after a vagrant halt and vagrant up.

This are my steps for the test:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'precise32'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] ** Creating adapter for persistent storage **
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] ** Persistent Storage Volume exists, not creating **
[default] ** Attaching persistent storage **
[default] ** Managing persistent storage **
[default] Mounting shared folders...
[default] -- /vagrant
$ vagrant ssh -c 'sudo fdisk -l /dev/sdb'

Disk /dev/sdb: 5242 MB, 5242880000 bytes
255 heads, 63 sectors/track, 637 cylinders, total 10240000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1    10233404     5116702   8e  Linux LVM
$ vagrant ssh -c 'sudo touch /var/lib/mysql/testfile'
$ vagrant halt
[default] Attempting graceful shutdown of VM...
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] ** Creating adapter for persistent storage **
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] ** Persistent Storage Volume exists, not creating **
[default] ** Attaching persistent storage **
[default] ** Managing persistent storage **
[default] Mounting shared folders...
[default] -- /vagrant
$ vagrant ssh -c 'sudo fdisk -l /dev/sdb'
$ vagrant ssh -c 'ls -l /var/lib/mysql/'
ls: reading directory /var/lib/mysql/: Input/output error
total 0

@madAndroid
Copy link
Contributor

Hi, I've made a number of changes to address the issues you've discovered during your testing, @kusnier

I've tested 'halt', 'suspend' and 'reload', in both an Ubuntu Precise and CentOS 6.4 Virtualbox VMs, on an Ubuntu host machine. Please could you run your tests again?

thanks :)

@kusnier
Copy link
Owner

kusnier commented Sep 8, 2013

Tested, no problems found. Nice work!
Please do a pull-request. I will then merge the changes and create a new version.

@madAndroid
Copy link
Contributor

fantastic! thank you very much :D

pull request coming right up ...

@kusnier
Copy link
Owner

kusnier commented Sep 8, 2013

Version 0.0.3 released.

@kusnier kusnier closed this as completed Sep 8, 2013
@thasmo
Copy link

thasmo commented Sep 8, 2013

Uh ye, didn't have time but nice to see this fixed/merged! :)

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

5 participants