Yaniv Bronhaim has posted comments on this change.
Change subject: libvirtconnection: ping libvirt upon disconnection ......................................................................
Patch Set 3:
(4 comments)
.................................................... File lib/vdsm/libvirtconnection.py Line 70: Wrap methods of connection object so that they catch disconnection, and Line 71: take the current process down. Line 72: """ Line 73: def wrapMethod(conn, f): Line 74: def wrapper(vdsmLibvirtPing=False, *args, **kwargs): I prefer to omit this variable and don't wrap getLibVersion at all. when testing connectivity we'll call to conn.getLibVersion and if libvirtError is raise we can suicide. Line 75: try: Line 76: ret = f(*args, **kwargs) Line 77: if isinstance(ret, libvirt.virDomain): Line 78: for name in dir(ret):
Line 90: libvirt.VIR_ERR_NO_CONNECT, Line 91: libvirt.VIR_ERR_INVALID_CONN) Line 92: if edom in EDOMAINS and ecode in ECODES: Line 93: if not vdsmLibvirtPing: Line 94: conn.getLibVersion(vdsmLibvirtPing=True) why block? doesn't matter much .. first fail ping we'll die, doesn't matter if in parallel another ping call runs Line 95: else: Line 96: log.error('connection to libvirt broken.' Line 97: ' ecode: %d edom: %d', ecode, edom) Line 98: if killOnFailure:
Line 92: if edom in EDOMAINS and ecode in ECODES: Line 93: if not vdsmLibvirtPing: Line 94: conn.getLibVersion(vdsmLibvirtPing=True) Line 95: else: Line 96: log.error('connection to libvirt broken.' not related to the patch much, change it in another patch Line 97: ' ecode: %d edom: %d', ecode, edom) Line 98: if killOnFailure: Line 99: log.error('taking calling process down.') Line 100: os.kill(os.getpid(), signal.SIGTERM)
Line 104: 'level: %d message: %s', ecode, edom, Line 105: e.get_error_level(), e.get_error_message()) Line 106: raise Line 107: wrapper.__name__ = f.__name__ Line 108: wrapper.__doc__ = f.__doc__ just use @wraps(f) in the same patch you change the logs level Line 109: return wrapper Line 110: Line 111: def req(credentials, user_data): Line 112: passwd = file(constants.P_VDSM_LIBVIRT_PASSWD).readline().rstrip("\n")