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): ...@@ -335,6 +335,12 @@ def check_required_only_partitions(existing, required):
return required return required
class SlapgridException(Exception):
pass
class NotConnectedToSlapOSMaster(SlapgridException):
pass
class Slapgrid(object): class Slapgrid(object):
""" Main class for SlapGrid. Fetches and processes informations from master """ Main class for SlapGrid. Fetches and processes informations from master
server and pushes usage information to master server. server and pushes usage information to master server.
...@@ -1422,12 +1428,10 @@ stderr_logfile_backups=1 ...@@ -1422,12 +1428,10 @@ stderr_logfile_backups=1
def processComputerPartitionList(self): def processComputerPartitionList(self):
try: try:
return self.processComputerPartitionListOnline() return self.processComputerPartitionListOnline()
except (RequestException, ConnectionError): except NotConnectedToSlapOSMaster:
# XXX Romain Why catching all errors?
# We should only check getting global state of comp # We should only check getting global state of comp
# and going offline in this case # and going offline in this case
raise return self.processComputerPartitionListOffline()
# return self.processComputerPartitionListOffline()
def processComputerPartitionListOnline(self): def processComputerPartitionListOnline(self):
""" """
...@@ -1443,7 +1447,15 @@ stderr_logfile_backups=1 ...@@ -1443,7 +1447,15 @@ stderr_logfile_backups=1
# Boolean to know if every promises correctly passed # Boolean to know if every promises correctly passed
clean_run_promise = True clean_run_promise = True
try:
computer_partition_list = self.getRequiredComputerPartitionList() 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 = [] process_error_partition_list = []
promise_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