diff --git a/tendrl/commons/objects/node_context/__init__.py b/tendrl/commons/objects/node_context/__init__.py index 46e723e2..9ee3b08a 100644 --- a/tendrl/commons/objects/node_context/__init__.py +++ b/tendrl/commons/objects/node_context/__init__.py @@ -93,6 +93,11 @@ def render(self): def save(self, update=True, ttl=None): super(NodeContext, self).save(update) status = self.value + "/status" + if self.status == "UP" and ttl == None: + # Set ttl always when node status in up + ttl = int( + NS.config.data.get("sync_interval", 60) + ) if ttl: self._ttl = ttl try: @@ -141,7 +146,10 @@ def on_change(self, attr, prev_value, current_value): _index_key = "/indexes/tags/%s" % _tag self.tags.remove(_tag) self.save() - etcd_utils.delete(_index_key) + try: + etcd_utils.delete(_index_key) + except etcd.EtcdKeyNotFound: + pass if _tc.sds_name in ["gluster", "RHGS"]: bricks = etcd_utils.read( "clusters/{0}/Bricks/all/{1}".format( diff --git a/tendrl/commons/utils/central_store/utils.py b/tendrl/commons/utils/central_store/utils.py index db010b63..3bbbd25e 100644 --- a/tendrl/commons/utils/central_store/utils.py +++ b/tendrl/commons/utils/central_store/utils.py @@ -107,7 +107,8 @@ def watch(obj, key): attr = key.rstrip("/").split("/")[-1] obj.on_change(attr, prev_val, cur_val) - except etcd.EtcdKeyNotFound: + except Exception: + # When watch crash then clear key from the watchers NS._int.watchers.pop(key, None) return