From fb3258e3952a5844dddb1d5bba8fee286ccc69f9 Mon Sep 17 00:00:00 2001 From: zhuyj17 Date: Sun, 5 May 2019 23:58:50 +0800 Subject: [PATCH] fix some bugs in monitor --- src/worker/monitor.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/worker/monitor.py b/src/worker/monitor.py index 99170ed..a5c4af0 100755 --- a/src/worker/monitor.py +++ b/src/worker/monitor.py @@ -372,7 +372,7 @@ class Container_Collector(threading.Thread): # deal with network used data containerids = re.split("-",container_name) - if not is_batch and len(containerids) >= 3: + if not is_batch and len(containerids) >= 3 and (containerids[1] + "-" + containerids[2]) in self.net_stats.keys(): workercinfo[container_name]['net_stats'] = self.net_stats[containerids[1] + '-' + containerids[2]] #logger.info(workercinfo[container_name]['net_stats']) @@ -658,7 +658,11 @@ class History_Manager: laststopruntime[vnode_name] = runtime vnode.laststopruntime = runtime db.session.add(history) - db.session.commit() + try: + db.session.commit() + except Exception as err: + db.session.rollback() + logger.warning(traceback.format_exc()) def getHistory(self,vnode_name): vnode = VNode.query.filter_by(name=vnode_name).first()