[Cluster-devel] conga/luci/site/luci/Extensions cluster_adapte ...
rmccabe at sourceware.org
rmccabe at sourceware.org
Tue Oct 24 14:08:51 UTC 2006
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2006-10-24 14:08:50
Modified files:
luci/site/luci/Extensions: cluster_adapters.py
Log message:
more logging/exception code for debugging
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.125&r2=1.126
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2006/10/20 22:29:22 1.125
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2006/10/24 14:08:50 1.126
@@ -443,7 +443,7 @@
try:
resObj = resourceAddHandler[res_type](self, dummy_form)
except:
- luci_log
+ luci_log('res type %d is invalid' % res_type)
resObj = None
if resObj is None:
@@ -2009,6 +2009,7 @@
try:
clustername = request.form['clusterName']
except:
+ luci_log.debug('missing cluster name for NTP')
return None
try:
@@ -2017,20 +2018,21 @@
try:
nodename = request.form['nodename']
except:
+ luci_log.debug('missing nodename name for NTP')
return None
try:
task = request['task']
- if not task:
- raise
except KeyError, e:
try:
task = request.form['task']
except:
+ luci_log.debug('missing task for NTP')
return None
nodename_resolved = resolve_nodename(self, clustername, nodename)
if not nodename_resolved or not nodename or not task or not clustername:
+ luci_log.debug('resolve_nodename failed for NTP')
return None
if task != NODE_FENCE:
@@ -2078,22 +2080,42 @@
return None
if task == NODE_LEAVE_CLUSTER:
- batch_number, result = nodeLeaveCluster(rc)
+ path = str(CLUSTER_FOLDER_PATH + clustername + "/" + nodename_resolved)
- path = CLUSTER_FOLDER_PATH + clustername + "/" + nodename_resolved
- nodefolder = self.restrictedTraverse(path)
+ try:
+ nodefolder = self.restrictedTraverse(path)
+ if not nodefolder:
+ raise Exception, 'cannot find directory at %s' % path
+ except Exception, e:
+ luci_log.debug('node_leave_cluster err: %s' % str(e))
+ return None
+
+ objname = str(nodename_resolved + "____flag")
+
+ fnpresent = noNodeFlagsPresent(self, nodefolder, objname, nodename_resolved)
+ if fnpresent is None:
+ luci_log.debug('An error occurred while checking flags for %s' \
+ % nodename_resolved)
+ return None
+
+ if fnpresent == False:
+ luci_log.debug('flags are still present for %s -- bailing out' \
+ % nodename_resolved)
+ return None
+
+ batch_number, result = nodeLeaveCluster(rc)
batch_id = str(batch_number)
- objname = nodename_resolved + "____flag"
- if noNodeFlagsPresent(self, nodefolder, objname, nodename_resolved) == False:
- raise UnknownClusterError("Fatal", "An unfinished task flag exists for node %s" % nodename)
- nodefolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
- #Now we need to annotate the new DB object
- objpath = path + "/" + objname
- flag = self.restrictedTraverse(objpath)
- flag.manage_addProperty(BATCH_ID,batch_id, "string")
- flag.manage_addProperty(TASKTYPE,NODE_LEAVE_CLUSTER, "string")
- flag.manage_addProperty(FLAG_DESC,"Node \'" + nodename + "\' leaving cluster", "string")
+ objpath = str(path + "/" + objname)
+ try:
+ nodefolder.manage_addProduct['ManagedSystem'].addManagedSystem(objname)
+ #Now we need to annotate the new DB object
+ flag = self.restrictedTraverse(objpath)
+ flag.manage_addProperty(BATCH_ID, batch_id, "string")
+ flag.manage_addProperty(TASKTYPE,NODE_LEAVE_CLUSTER, "string")
+ flag.manage_addProperty(FLAG_DESC,"Node \'" + nodename + "\' leaving cluster", "string")
+ except:
+ luci_log.debug('An error occurred while setting flag %s' % objpath)
response = request.RESPONSE
#Is this correct? Should we re-direct to the cluster page?
@@ -2670,22 +2692,29 @@
try:
cluname = req.form['clusterName']
except:
+ luci_log.debug_verbose('No cluster name -- returning empty map')
return map
path = CLUSTER_FOLDER_PATH + cluname
try:
clusterfolder = self.restrictedTraverse(str(path))
if not clusterfolder:
- raise
- except:
+ raise Exception, 'clusterfolder is None'
+ except Exception, e:
+ luci_log.debug_verbose('cluster %s [%s] folder missing: %s -- returning empty map' % (cluname, path, str(e)))
return map
+ except:
+ luci_log.debug_verbose('cluster %s [%s] folder missing: returning empty map' % (cluname, path))
try:
items = clusterfolder.objectItems('ManagedSystem')
if not items or len(items) < 1:
return map #This returns an empty map, and should indicate not busy
+ except Exception, e:
+ luci_log.debug('An error occurred while looking for cluster %s flags at path %s: %s' % (cluname, path, str(e)))
+ return map
except:
- luci_log.debug('An error occurred while looking for cluster %s flags' % cluname)
+ luci_log.debug('An error occurred while looking for cluster %s flags at path %s' % (cluname, path))
return map
map['busy'] = "true"
@@ -2716,14 +2745,30 @@
node_report['desc'] = item[1].getProperty(FLAG_DESC)
batch_xml = None
ricci = item[0].split("____") #This removes the 'flag' suffix
+
try:
rc = RicciCommunicator(ricci[0])
- batch_xml = rc.batch_report(item[1].getProperty(BATCH_ID))
- if batch_xml != None:
- (creation_status, total) = batch_status(batch_xml)
+ except RicciError, e:
+ rc = None
+ luci_log.debug_verbose('ricci returned error in iCB for %s: %s' \
+ % (cluname, str(e)))
except:
- creation_status = RICCI_CONNECT_FAILURE #No contact with ricci (-1000)
- batch_xml = "bloody_failure" #set to avoid next if statement
+ rc = None
+ luci_log.info('ricci connection failed for cluster %s' % cluname)
+
+ if rc is not None:
+ try:
+ batch_xml = rc.batch_report(item[1].getProperty(BATCH_ID))
+ if batch_xml != None:
+ (creation_status, total) = batch_status(batch_xml)
+ else:
+ luci_log.debug_verbose('batch report for cluster %s, item %s is None' % (cluname, item[0]))
+ except:
+ creation_status = RICCI_CONNECT_FAILURE #No contact with ricci (-1000)
+ batch_xml = "bloody_failure" #set to avoid next if statement
+ else:
+ creation_status = RICCI_CONNECT_FAILURE #No contact with ricci (-1000)
+ batch_xml = "bloody_failure" #set to avoid next if statement
if batch_xml == None: #The job is done and gone from queue
if redirect_message == False: #We have not displayed this message yet
@@ -2732,6 +2777,8 @@
node_report['errormessage'] = ""
nodereports.append(node_report)
redirect_message = True
+
+ luci_log.debug_verbose('batch job is done -- deleting %s' % item[0])
clusterfolder.manage_delObjects(item[0])
continue
@@ -3620,7 +3667,7 @@
items = nodefolder.objectItems('ManagedSystem')
except:
luci_log.debug('An error occurred while trying to list flags for cluster ' + nodefolder[0])
- return False
+ return None
for item in items:
if item[0] != flagname:
@@ -3631,7 +3678,7 @@
rc = RicciCommunicator(hostname)
except RicciError, e:
luci_log.info('Unable to connect to the ricci daemon: %s' % str(e))
- return False
+ return None
if not rc.authed():
try:
@@ -3649,11 +3696,12 @@
except Exception, e:
luci_log.info('manage_delObjects for %s failed: %s' \
% (item[0], str(e)))
- return False
+ return None
return True
else:
#Not finished, so cannot remove flag
return False
+
return True
def getModelBuilder(rc, isVirtualized):
More information about the Cluster-devel
mailing list