Commit 92392f62 authored by Romain Courteaud's avatar Romain Courteaud 🐸

grid/slapgrid: reduce cases when slapgrid switch to offline mode

parent e90ff84e
......@@ -335,6 +335,12 @@ def check_required_only_partitions(existing, required):
return required
class SlapgridException(Exception):
pass
class NotConnectedToSlapOSMaster(SlapgridException):
pass
class Slapgrid(object):
""" Main class for SlapGrid. Fetches and processes informations from master
server and pushes usage information to master server.
......@@ -1422,12 +1428,10 @@ stderr_logfile_backups=1
def processComputerPartitionList(self):
try:
return self.processComputerPartitionListOnline()
except (RequestException, ConnectionError):
# XXX Romain Why catching all errors?
except NotConnectedToSlapOSMaster:
# We should only check getting global state of comp
# and going offline in this case
raise
# return self.processComputerPartitionListOffline()
return self.processComputerPartitionListOffline()
def processComputerPartitionListOnline(self):
"""
......@@ -1443,7 +1447,15 @@ stderr_logfile_backups=1
# Boolean to know if every promises correctly passed
clean_run_promise = True
computer_partition_list = self.getRequiredComputerPartitionList()
try:
computer_partition_list = self.getRequiredComputerPartitionList()
except (RequestException, ConnectionError) as exc:
# If connection to the slapos master fails
# while retrieving compute node state,
# switch to the offline mode
# Log the exception to understand why it switched to offline mode
self.logger.error(exc)
raise NotConnectedToSlapOSMaster
process_error_partition_list = []
promise_error_partition_list = []
......
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