masakari-introspectiveinstancemonitor: the code ofmethod checkGuests could not work

Bug #2046532 reported by leelswngsh
24
This bug affects 3 people
Affects Status Importance Assigned to Milestone
masakari-monitors
New
Undecided
Unassigned

Bug Description

In the masakari-introspectiveinstancemonitor log :

WARNING masakarimonitors.introspectiveinstancemonitor.qemu_utils [-] Failed to connect socket to '/var/lib/masakari/.cache/libvirt/libvirt-sock': No such file or directory: libvirt.libvirtError: Failed to connect socket to '/var/lib/masakari/.cache/libvirt/libvirt-sock': No such file or directory

As a result,it can not to detect the vm state,so i modify the file masakari-monitors/masakarimonitors/introspectiveinstancemonitor/qemu_utils.py as below:

    def checkGuests(self):
        """Function: Check QEMU Guests

        Condition: VM under intrusive monitoring must have QEMU agent client
        configured, installed and qemu "guest-agent-pingable".
        """

        try:
            # conn = libvirt.open(None) # LIBVIRT_DEFAULT_URI
            conn = libvirt.open(CONF.libvirt.connection_uri)
            ids = conn.listDomainsID()

            for domainID in ids:
                domain = conn.lookupByID(domainID)
                if domain:
                    try:
                        if self._hasQemuGuestAgent(domain):
                            @utils.synchronized(domain.UUIDString())
                            def do_qemuAgentGuestPing(domain, timeout):
                                self._qemuAgentGuestPing(domain, timeout)

                            do_qemuAgentGuestPing(domain,
                                                  ICONF.guest_monitoring_timeout)
                    except libvirt.libvirtError as le:
                        LOG.warning(le)
                        continue
        except Exception as e:
            LOG.warning(e)
            pass

After testing with the code , it works well .

Revision history for this message
Alexey 'Fenuks' Rusetsky (fenuks-uh) wrote :

I can confirm that this code works. LIBVIRT_DEFAULT_URI is only set through /etc/profile, so not available to systemd services.

Also this code does not appear to change anything through libvirt, so should also work in readonly mode:

conn = libvirt.openReadOnly(CONF.libvirt.connection_uri)

readOnly socket is world readable on debian/ubuntu and does not require masakari user to be in libvirt group.

Think we can set https://bugs.launchpad.net/masakari-monitors/+bug/1844603 and https://bugs.launchpad.net/masakari-monitors/+bug/1844295 as duplicates of this report?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.