mitchellh/vagrant-google

Add guard method for image_family selector

Temikus opened this issue · 4 comments

If image family does not exist we trace back:

undefined method `self_link' for nil:NilClass

/Users/temikus/.vagrant.d/gems/2.4.3/gems/vagrant-google-2.0.0/lib/vagrant-google/action/run_instance.rb:99:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in `call'
/Users/temikus/.vagrant.d/gems/2.4.3/gems/vagrant-google-2.0.0/lib/vagrant-google/action/warn_ssh_keys.rb:28:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in `call'
/Users/temikus/.vagrant.d/gems/2.4.3/gems/vagrant-google-2.0.0/lib/vagrant-google/action/warn_networks.rb:28:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builtin/synced_folders.rb:87:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builtin/provision.rb:80:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builder.rb:116:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/runner.rb:66:in `block in run'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/util/busy.rb:19:in `busy'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/runner.rb:66:in `run'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builtin/call.rb:53:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in `call'
/Users/temikus/.vagrant.d/gems/2.4.3/gems/vagrant-google-2.0.0/lib/vagrant-google/action/connect_google.rb:44:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builtin/box_check_outdated.rb:79:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/warden.rb:34:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/builder.rb:116:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/runner.rb:66:in `block in run'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/util/busy.rb:19:in `busy'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/action/runner.rb:66:in `run'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/machine.rb:227:in `action_raw'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/machine.rb:202:in `block in action'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/environment.rb:592:in `lock'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/machine.rb:188:in `call'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/machine.rb:188:in `action'
/opt/vagrant/embedded/gems/2.0.3/gems/vagrant-2.0.3/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'

Need a guard method that rolls back the process of machine creation here:

image = env[:google_compute].images.get_from_family(image_family, image_project_id).self_link

Should update the docs example aswell to account for this..

I got the example working by adding:

google.image_project_id = "ubuntu-os-cloud"

@fatmcgav Thank you for this. I missed a piece of logic here. Default image project id's should be autopopulated. I'll address this in the nearest patch.

@fatmcgav what you've experienced is actually a regression, apologies - see #206. I'll roll out a fix today.