fog / fog-libvirt

libvirt provider for fog
MIT License
16 stars 42 forks source link

dhcp_leases.rb:8:in `dhcp_leases': Call to virNetworkGetDHCPLeases failed: internal error: no lease with matching MAC address: 52:54:00:32:36:b7 (Libvirt::Error) #28

Closed infernix closed 3 years ago

infernix commented 7 years ago

When calling dhcp_leases with a mac that does not exist, libvirt throws an error.

/root/.vagrant.d/gems/gems/fog-libvirt-0.3.0/lib/fog/libvirt/requests/compute/dhcp_leases.rb:8:in `dhcp_leases': Call to virNetworkGetDHCPLeases failed: internal error: no lease with matching MAC address: 52:54:00:32:36:b7 (Libvirt::Error)
    from /root/.vagrant.d/gems/gems/fog-libvirt-0.3.0/lib/fog/libvirt/requests/compute/dhcp_leases.rb:8:in `dhcp_leases'
    from /root/.vagrant.d/gems/gems/fog-libvirt-0.3.0/lib/fog/libvirt/models/compute/network.rb:20:in `dhcp_leases'
    from /root/.vagrant.d/gems/gems/fog-libvirt-0.3.0/lib/fog/libvirt/models/compute/server.rb:272:in `block in addresses'
    from /root/.vagrant.d/gems/gems/fog-core-1.43.0/lib/fog/core/collection.rb:19:in `each'
    from /root/.vagrant.d/gems/gems/fog-core-1.43.0/lib/fog/core/collection.rb:19:in `each'
    from /root/.vagrant.d/gems/gems/fog-libvirt-0.3.0/lib/fog/libvirt/models/compute/server.rb:270:in `addresses'
    from /root/.vagrant.d/gems/gems/vagrant-libvirt-0.0.36/lib/vagrant-libvirt/action/wait_till_up.rb:44:in `block (3 levels) in call'
...

vagrant-libvirt calls def addresses in a while loop, waiting for a VM to boot and retrying until an IP is returned (with an eventual timeout). Since PR #11 this fails due to a functional change.

I believe this case should be handled correctly and return nil for def addresses(service_arg=service, options={}) as it was before so that this doesn't break existing functionality. Or is the failure here intentional?

plribeiro3000 commented 7 years ago

I believe this was not intentional. Perhaps we can fix this together with #27?

mrvovanness commented 7 years ago

I encountered the same issue, using debian 8.6 host with libvirt 1.2.9, vagrant 1.8.6 and vagrant-libvirt-0.0.36 . As a temporal workaround I edited the source code, but I don't sure if this appropriate:

        def dhcp_leases(uuid, mac, flags = 0)
          client.lookup_network_by_uuid(uuid).dhcp_leases(mac, flags)
        rescue => e
          if e.message =~ /no lease with matching MAC address/
            return []
          end
          raise e.class, e.message
        end
alexggolovin commented 7 years ago

Same issue on Debian 8.8 with vagrant-libvirt (0.0.40) installed from vagrant-libvirt repository due to this workaround https://github.com/vagrant-libvirt/vagrant-libvirt/issues/770 has been fixed with workaround provided by mrvovanness

alexggolovin commented 7 years ago

Supposed to be fixed in new Debian versions due to this reports: https://www.redhat.com/archives/libvir-list/2015-January/msg00055.html And this commit: https://github.com/libvirt/libvirt/commit/18ec863d19bdaf517e26642f794b7ee4d1d2c53f

github-actions[bot] commented 3 years ago

This issue has been marked inactive and will be closed if no further activity occurs.