ggiamarchi / vagrant-openstack-provider

Use Vagrant to manage OpenStack Cloud instances.
MIT License
245 stars 102 forks source link

Finding network(s) for server... Server broke connection... #317

Closed KrystianMarek closed 7 years ago

KrystianMarek commented 7 years ago

This happens each time I try to run vagrant up

==> default: Finding network(s) for server...
2017-02-14 00:41 | DEBUG | get_networks - start
2017-02-14 00:41 | DEBUG | request  => method  : GET
2017-02-14 00:41 | DEBUG | request  => url     : http://my-awesome-openstack:9696/v2.0/networks
2017-02-14 00:41 | DEBUG | request  => headers : {"X-Auth-Token"=>"SECRET_TOKEN", :accept
=>:json}
An unknown error happened in Vagrant OpenStack provider

Stack trace: http://pastebin.com/iXnVrJ1D

describe features you would like to see in this provider.
/opt/vagrant/embedded/gems/gems/rest-client-2.0.0/lib/restclient/request.rb:780:in `rescue in transmit': Server broke connection (RestClient::ServerBrokeConnection)
        from /opt/vagrant/embedded/gems/gems/rest-client-2.0.0/lib/restclient/request.rb:698:in `transmit'
        from /opt/vagrant/embedded/gems/gems/rest-client-2.0.0/lib/restclient/request.rb:215:in `execute'
        from /opt/vagrant/embedded/gems/gems/rest-client-2.0.0/lib/restclient/request.rb:52:in `execute'
        from /home/marek/.vagrant.d/gems/2.2.5/gems/vagrant-openstack-provider-0.9.0/lib/vagrant-openstack-provider/client/rest_utils.rb:8:in `get'
        from /home/marek/.vagrant.d/gems/2.2.5/gems/vagrant-openstack-provider-0.9.0/lib/vagrant-openstack-provider/client/http_utils.rb:22:in `block in get'
        from /home/marek/.vagrant.d/gems/2.2.5/gems/vagrant-openstack-provider-0.9.0/lib/vagrant-openstack-provider/client/http_utils.rb:104:in `authenticated'
        from /home/marek/.vagrant.d/gems/2.2.5/gems/vagrant-openstack-provider-0.9.0/lib/vagrant-openstack-provider/client/http_utils.rb:21:in `get'
        from /home/marek/.vagrant.d/gems/2.2.5/gems/vagrant-openstack-provider-0.9.0/lib/vagrant-openstack-provider/client/neutron.rb:39:in `get_networks'
        from /home/marek/.vagrant.d/gems/2.2.5/gems/vagrant-openstack-provider-0.9.0/lib/vagrant-openstack-provider/client/neutron.rb:24:in `get_all_networks'
        from /home/marek/.vagrant.d/gems/2.2.5/gems/vagrant-openstack-provider-0.9.0/lib/vagrant-openstack-provider/config_resolver.rb:64:in `resolve_networks'
        from /home/marek/.vagrant.d/gems/2.2.5/gems/vagrant-openstack-provider-0.9.0/lib/vagrant-openstack-provider/action/create_server.rb:36:in `execute'
        from /home/marek/.vagrant.d/gems/2.2.5/gems/vagrant-openstack-provider-0.9.0/lib/vagrant-openstack-provider/action/abstract_action.rb:8:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
        from /home/marek/.vagrant.d/gems/2.2.5/gems/vagrant-openstack-provider-0.9.0/lib/vagrant-openstack-provider/action/create_stack.rb:54:in `execute'
        from /home/marek/.vagrant.d/gems/2.2.5/gems/vagrant-openstack-provider-0.9.0/lib/vagrant-openstack-provider/action/abstract_action.rb:8:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/synced_folders.rb:87:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/provision.rb:80:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builder.rb:116:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `block in run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/util/busy.rb:19:in `busy'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/call.rb:53:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
        from /home/marek/.vagrant.d/gems/2.2.5/gems/vagrant-openstack-provider-0.9.0/lib/vagrant-openstack-provider/action/connect_openstack.rb:32:in `execute'
        from /home/marek/.vagrant.d/gems/2.2.5/gems/vagrant-openstack-provider-0.9.0/lib/vagrant-openstack-provider/action/abstract_action.rb:8:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builtin/handle_box.rb:25:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/warden.rb:34:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/builder.rb:116:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `block in run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/util/busy.rb:19:in `busy'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/action/runner.rb:66:in `run'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/machine.rb:225:in `action_raw'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/machine.rb:200:in `block in action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/environment.rb:567:in `lock'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/machine.rb:186:in `call'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/machine.rb:186:in `action'
        from /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'

Vagrantfile:

require 'vagrant-openstack-provider'

Vagrant.configure('2') do |config|

  config.ssh.username = 'stack'

  config.vm.provider :openstack do |os|
    config.env.enable
    os.openstack_auth_url = 'https://my-awesome-openstack:5000/v2.0'
    os.username           = 'marek'
    os.password           = ENV['PASS']
    os.domain_name        = 'default'
    os.project_name       = 'marek'
    os.tenant_name        = 'marek'
    os.flavor             = 'm1.small'
    os.image              = 'ubuntu-14.04-server-amd64'
    os.security_groups    = ['default'] 
    os.networks           = [{ id:"20d46c9f-5718-4a3c-a0d3-632f06a0b7de" }]
  end
end
ggiamarchi commented 7 years ago

@KrystianMarek i have a few questions in order to be able to help you with this issue :

averstappen commented 7 years ago

I'm seeing the same issue, with me it seems to be caused by vagrant-openstack-provider resolving the url to neutron to be http://my-awesome../v2.0/networks, where in my case that should be over ssl, so https://my-awesome../v2.0/networks.

Trying the suggested curl command with the URL taken from debug info will hang forever, changing it into https will return a json.

When hacking .vagrant.d/gems/2.2.5/gems/vagrant-openstack-provider-0.9.0/lib/vagrant-openstack-provider/client/neutron.rb changing at line 38:

   def get_networks(env, all)
      networks_json = get(env, "#{@session.endpoints[:network]}/networks")

into

  def get_networks(env, all)
      networks_json = get(env, "https://my-awesome-neutron/v2.0/networks")

I can succesfully 'vagrant up' a machine. Sadly, I don't have the ruby skills to find the correct spot to correct the URL, or to find out if it is vagrant-openstack-provider resolving the URL incorrectly, or my openstack installation sending incorrect information.

Hope this helps, if there are further debug steps I could perform to gather information, let me know.

[edit] Just read the documentation and found that I can override the detected endpoint by specifying os.openstack_network_url in the VagrantFile. No need to hack the source.

xdanos commented 7 years ago

@averstappen, you can override the networks endpoint url as follows:

 config.vm.provider :openstack do |os|
    config.env.enable
    ...
    os.openstack_auth_url = 'https://my-awesome-openstack:5000/v2.0'
    os.openstack_network_url = 'https://my-awesome-openstack:9696/v2.0'
    ...
  end

This should help as a hotfix.

averstappen commented 7 years ago

@xdanos: yes, that works, thank you. Much better than my lousy code-hack :-)

ggiamarchi commented 7 years ago

@averstappen Please have a look at this old comment https://github.com/ggiamarchi/vagrant-openstack-provider/issues/128#issuecomment-65283223. I would bet this is the reason why the plugin resolve a HTTP address instead of a HTTPS address. The endpoint URL resolver in the plugin is implemented the good way but unfortunately the lack of SSL termination support in OpenStack (i don't if this point has evolved in the last past year...) a lot of OpenStack HTTPS deployments have this problem. So, the best solution would be to fix this at the OpenStack level. By the way, the workaround given by @xdanos is the good one

ggiamarchi commented 7 years ago

I think no more action is required on this one. Feel free to open a new issue if you guys still encounter any problem