Commit b70edc75 authored by Antoine Catton's avatar Antoine Catton

Mostly working version of watchdog.

Need to be fully tested.
parent 4d444533
...@@ -46,7 +46,8 @@ def main(): ...@@ -46,7 +46,8 @@ def main():
while True: while True:
time.sleep(args.frequency) time.sleep(args.frequency)
server.get_master() server.get_master()
server.think(1) # XXX: Hard coding 5 minutes
server.think(5)
......
...@@ -39,10 +39,16 @@ from slapos.slap import slap ...@@ -39,10 +39,16 @@ from slapos.slap import slap
def get_status(feed_content): def get_status(feed_content):
feed = feedparser.parse(feed_content) feed = feedparser.parse(feed_content)
# Just for test purpose
# here should be the algorithm saying if we error_amount = 0
# should rename or not the partition. for entry in feed.entries:
return False if 'FAIL' in entry.content:
error_amount += 1
# XXX: Hard coding maximum error amount
# is 3.
if error_amount >= 3:
return False
return True
def get_timestamp(minutes_ago): def get_timestamp(minutes_ago):
result = datetime.datetime.now() result = datetime.datetime.now()
...@@ -120,10 +126,6 @@ class Server(Connector): ...@@ -120,10 +126,6 @@ class Server(Connector):
for url in json.loads(connector.GET('getPeers').read())]) for url in json.loads(connector.GET('getPeers').read())])
except: except:
pass pass
# For debug purpose only.
# Need to be remove in the future in order to
# swallow everything
raise
@staticmethod @staticmethod
def _convert_uuid(id_): def _convert_uuid(id_):
...@@ -141,10 +143,6 @@ class Server(Connector): ...@@ -141,10 +143,6 @@ class Server(Connector):
type_ = value.GET('info/type').read() type_ = value.GET('info/type').read()
except: except:
pass pass
# For debug purpose only.
# Need to be remove in the future in order to
# swallow everything
raise
else: else:
to_set_none = deque() to_set_none = deque()
# Look for peer having same type (type should be unique) # Look for peer having same type (type should be unique)
...@@ -182,10 +180,6 @@ class Server(Connector): ...@@ -182,10 +180,6 @@ class Server(Connector):
failed_list.append(peer) failed_list.append(peer)
except: except:
pass pass
# For debug purpose only.
# Need to be remove in the future in order to
# swallow everything
raise
return self.get_peer_id(id_).geturl() return self.get_peer_id(id_).geturl()
...@@ -236,10 +230,6 @@ class Server(Connector): ...@@ -236,10 +230,6 @@ class Server(Connector):
pass pass
except: except:
pass pass
# For debug purpose only.
# Need to be remove in the future in order to
# swallow everything
raise
def get_type(self, type_): def get_type(self, type_):
for peer_type, peer in self._peers.itervalues(): for peer_type, peer in self._peers.itervalues():
...@@ -257,6 +247,8 @@ class Server(Connector): ...@@ -257,6 +247,8 @@ class Server(Connector):
def down(self, connector): def down(self, connector):
new_name = 'down_%s' % uuid.uuid4().hex new_name = 'down_%s' % uuid.uuid4().hex
self.rename(connector, new_name) self.rename(connector, new_name)
# XXX: EXTREMELY Dirty Workaround to avoid bug #20120127-6487F8
time.sleep(10)
self.slaprequest(partition_reference=new_name, self.slaprequest(partition_reference=new_name,
software_type='down') software_type='down')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment