Martin Sivák has uploaded a new change for review.

Change subject: Add soft dependency on libvirt's metadata support to stats 
collector
......................................................................

Add soft dependency on libvirt's metadata support to stats collector

There is an issue with libvirt on CentOS 6. The available version does
not support part of the metadata API. This generates an error message
every 15 seconds.

This patch workarounds this by logging the error only once.

Revert once libvirt supports the xml element metadata on CentOS.

See bug: https://bugzilla.redhat.com/show_bug.cgi?id=1115039

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1114968
Change-Id: I3d38d3aff3bda42dfaafa87bab9fa5983fb4b9a8
Signed-off-by: Martin Sivak <[email protected]>
Reviewed-on: http://gerrit.ovirt.org/29504
Reviewed-by: Francesco Romani <[email protected]>
Reviewed-by: Nir Soffer <[email protected]>
Reviewed-by: Michal Skrivanek <[email protected]>
Reviewed-by: Dan Kenigsberg <[email protected]>
(cherry picked from commit 935123db785d0a848cfeae5e9cf8cc75ad598701)
---
M vdsm/virt/vm.py
1 file changed, 25 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/88/29788/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 234b75a..6cf7be2 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -184,6 +184,15 @@
     # minimum supported value is 2
     CPU_TUNE_SAMPLING_WINDOW = 2
 
+    # This flag will prevent excessive log flooding when running
+    # on libvirt with no support for metadata xml elements.
+    #
+    # The issue currently exists only on CentOS/RHEL 6.5 that
+    # ships libvirt-0.10.x.
+    #
+    # TODO: Remove as soon as there is a hard dependency we can use
+    _libvirt_metadata_supported = True
+
     def __init__(self, vm):
         sampling.AdvancedStatsThread.__init__(self, log=vm.log, daemon=True)
         self._vm = vm
@@ -312,11 +321,23 @@
         metadataCpuLimit = None
 
         try:
-            metadataCpuLimit = self._vm._dom.metadata(
-                libvirt.VIR_DOMAIN_METADATA_ELEMENT, METADATA_VM_TUNE_URI, 0)
+            if VmStatsThread._libvirt_metadata_supported:
+                metadataCpuLimit = self._vm._dom.metadata(
+                    libvirt.VIR_DOMAIN_METADATA_ELEMENT,
+                    METADATA_VM_TUNE_URI, 0)
         except libvirt.libvirtError as e:
-            if e.get_error_code() != libvirt.VIR_ERR_NO_DOMAIN_METADATA:
-                self._log.exception("Failed to retrieve QoS metadata")
+            if e.get_error_code() == libvirt.VIR_ERR_ARGUMENT_UNSUPPORTED:
+                VmStatsThread._libvirt_metadata_supported = False
+                self._log.error("libvirt does not support metadata")
+
+            elif (e.get_error_code()
+                  not in (libvirt.VIR_ERR_NO_DOMAIN,
+                          libvirt.VIR_ERR_NO_DOMAIN_METADATA)):
+                # Non-existing VM and no metadata block are expected
+                # conditions and no reasons for concern here.
+                # All other errors should be reported.
+                self._log.warn("Failed to retrieve QoS metadata because of %s",
+                               e)
 
         if metadataCpuLimit:
             metadataCpuLimitXML = _domParseStr(metadataCpuLimit)


-- 
To view, visit http://gerrit.ovirt.org/29788
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3d38d3aff3bda42dfaafa87bab9fa5983fb4b9a8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Martin Sivák <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to