Handle EPIPE Broken Pipe from Libvirt RPC

If Libvirt (virtqemud when modular or libvirtd when
using monolith) is restarted while we are polling
the RPC layer can return a EPIPE Broken Pipe (errcode
32) to us.

We should retry when we get this as the service might
be back again and we just got aborted because it was
restarted.

Change-Id: If273f6e9c26f992fb31fccf69d869d7494d41e30
Signed-off-by: Tobias Urdin <tobias.urdin@binero.com>
(cherry picked from commit 2a452552b3)
This commit is contained in:
Tobias Urdin
2025-08-20 11:33:43 +02:00
parent 87baa22317
commit f1d638faa1

View File

@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import errno
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
import tenacity import tenacity
@@ -107,11 +108,17 @@ def refresh_libvirt_connection(conf, klass):
def is_disconnection_exception(e): def is_disconnection_exception(e):
if not libvirt: if not libvirt:
return False return False
return (isinstance(e, libvirt.libvirtError) if not isinstance(e, libvirt.libvirtError):
and e.get_error_code() in (libvirt.VIR_ERR_SYSTEM_ERROR, return False
libvirt.VIR_ERR_INTERNAL_ERROR) is_libvirt_error = (
and e.get_error_domain() in (libvirt.VIR_FROM_REMOTE, e.get_error_code() in (libvirt.VIR_ERR_SYSTEM_ERROR,
libvirt.VIR_FROM_RPC)) libvirt.VIR_ERR_INTERNAL_ERROR)
and e.get_error_domain() in (libvirt.VIR_FROM_REMOTE,
libvirt.VIR_FROM_RPC))
is_system_error = (
e.get_error_domain() == libvirt.VIR_FROM_RPC
and e.get_error_code() == errno.EPIPE)
return is_libvirt_error or is_system_error
retry_on_disconnect = tenacity.retry( retry_on_disconnect = tenacity.retry(