Saggi Mizrahi has uploaded a new change for review.
Change subject: Refactor mom init error flow ......................................................................
Refactor mom init error flow
Splitting a log to to log invocation is bad because it could potentially separate the 2 log lines. Further more, it usually points out to a bad flow if you only sometimes need to log in the same flow so you resort to such tricks.
- Add proper exception when MomThread fails to initialize - Make the two error flows clear and have each logged properly
Change-Id: I03ff6057cdbb22b88ed2b5766bda399651c4d058 Signed-off-by: Saggi Mizrahi smizrahi@redhat.com --- M vdsm/clientIF.py M vdsm/momIF.py 2 files changed, 25 insertions(+), 10 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/81/9481/1
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py index 82603af..0bd686f 100644 --- a/vdsm/clientIF.py +++ b/vdsm/clientIF.py @@ -29,7 +29,7 @@ from storage.hsm import HSM from vdsm.config import config import ksm -from momIF import MomThread +from momIF import MomThread, isMomAvailable from vdsm import netinfo from vdsm.define import doneCode, errCode import libvirt @@ -189,14 +189,20 @@ 'Please make sure it is installed.')
def _prepareMOM(self): - try: - momconf = config.get("mom", "conf") - self.mom = MomThread(momconf) - except: - self.log.warn("MOM initialization failed and fall " - "back to KsmMonitor") - self.log.debug("Details:", exc_info=True) - self.ksmMonitor = ksm.KsmMonitorThread(self) + momconf = config.get("mom", "conf") + + if isMomAvailable(): + try: + self.mom = MomThread(momconf) + return + except: + self.log.warn("MOM initialization failed and fall " + "back to KsmMonitor", exc_info=True) + + else: + self.log.warn("MOM is not available, fallback to KsmMonitor") + + self.ksmMonitor = ksm.KsmMonitorThread(self)
def _syncLibvirtNetworks(self): """ diff --git a/vdsm/momIF.py b/vdsm/momIF.py index 827e9e4..807daef 100644 --- a/vdsm/momIF.py +++ b/vdsm/momIF.py @@ -27,11 +27,20 @@ _momAvailable = False
+class MomNotAvailableError(RuntimeError): + pass + + +def isMomAvailable(): + return _momAvailable + + class MomThread(threading.Thread):
def __init__(self, momconf): if not _momAvailable: - raise Exception("MOM is not available") + raise MomNotAvailableError() + self.log = logging.getLogger("MOM") self.log.info("Starting up MOM") self._mom = mom.MOM(momconf)
-- To view, visit http://gerrit.ovirt.org/9481 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: I03ff6057cdbb22b88ed2b5766bda399651c4d058 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Saggi Mizrahi smizrahi@redhat.com
oVirt Jenkins CI Server has posted comments on this change.
Change subject: Refactor mom init error flow ......................................................................
Patch Set 1:
Build Started http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/150/ (2/2)
-- To view, visit http://gerrit.ovirt.org/9481 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I03ff6057cdbb22b88ed2b5766bda399651c4d058 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Saggi Mizrahi smizrahi@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: Refactor mom init error flow ......................................................................
Patch Set 1:
Build Started http://jenkins.ovirt.org/job/vdsm_unit_tests_manual_gerrit/184/ (1/2)
-- To view, visit http://gerrit.ovirt.org/9481 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I03ff6057cdbb22b88ed2b5766bda399651c4d058 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Saggi Mizrahi smizrahi@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: Refactor mom init error flow ......................................................................
Patch Set 1:
Build Successful
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/150/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_manual_gerrit/184/ : SUCCESS
-- To view, visit http://gerrit.ovirt.org/9481 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I03ff6057cdbb22b88ed2b5766bda399651c4d058 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Saggi Mizrahi smizrahi@redhat.com Gerrit-Reviewer: Adam Litke agl@us.ibm.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Adam Litke has posted comments on this change.
Change subject: Refactor mom init error flow ......................................................................
Patch Set 1: Looks good to me, but someone else must approve
Looks good. Please test the various failure modes and then mark it verified.
-- To view, visit http://gerrit.ovirt.org/9481 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I03ff6057cdbb22b88ed2b5766bda399651c4d058 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Saggi Mizrahi smizrahi@redhat.com Gerrit-Reviewer: Adam Litke agl@us.ibm.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Doron Fediuck dfediuck@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Doron Fediuck has posted comments on this change.
Change subject: Refactor mom init error flow ......................................................................
Patch Set 1: Looks good to me, but someone else must approve
-- To view, visit http://gerrit.ovirt.org/9481 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I03ff6057cdbb22b88ed2b5766bda399651c4d058 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Saggi Mizrahi smizrahi@redhat.com Gerrit-Reviewer: Adam Litke agl@us.ibm.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Doron Fediuck dfediuck@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Dan Kenigsberg has submitted this change and it was merged.
Change subject: Refactor mom init error flow ......................................................................
Refactor mom init error flow
Splitting a log to to log invocation is bad because it could potentially separate the 2 log lines. Further more, it usually points out to a bad flow if you only sometimes need to log in the same flow so you resort to such tricks.
- Add proper exception when MomThread fails to initialize - Make the two error flows clear and have each logged properly
Change-Id: I03ff6057cdbb22b88ed2b5766bda399651c4d058 Signed-off-by: Saggi Mizrahi smizrahi@redhat.com --- M vdsm/clientIF.py M vdsm/momIF.py 2 files changed, 25 insertions(+), 10 deletions(-)
Approvals: Adam Litke: Looks good to me, but someone else must approve Doron Fediuck: Looks good to me, but someone else must approve Dan Kenigsberg: Verified; Looks good to me, approved
-- To view, visit http://gerrit.ovirt.org/9481 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: merged Gerrit-Change-Id: I03ff6057cdbb22b88ed2b5766bda399651c4d058 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Saggi Mizrahi smizrahi@redhat.com Gerrit-Reviewer: Adam Litke agl@us.ibm.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Doron Fediuck dfediuck@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Dan Kenigsberg has posted comments on this change.
Change subject: Refactor mom init error flow ......................................................................
Patch Set 1: Verified; Looks good to me, approved
yeah, I've verified this patch myself.
-- To view, visit http://gerrit.ovirt.org/9481 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I03ff6057cdbb22b88ed2b5766bda399651c4d058 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Saggi Mizrahi smizrahi@redhat.com Gerrit-Reviewer: Adam Litke agl@us.ibm.com Gerrit-Reviewer: Dan Kenigsberg danken@redhat.com Gerrit-Reviewer: Doron Fediuck dfediuck@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
vdsm-patches@lists.fedorahosted.org