Commit 14745358 authored by Xavier Thompson's avatar Xavier Thompson

slapgrid: Fix connectionless instance processing

Connection loss may result in `slap.exception.ConnectionError` being
raised during instance processing in addition to `RequestException`.
parent be11fd4f
...@@ -59,6 +59,7 @@ from requests.exceptions import RequestException ...@@ -59,6 +59,7 @@ from requests.exceptions import RequestException
from lxml import etree from lxml import etree
from slapos import manager as slapmanager from slapos import manager as slapmanager
from slapos.slap.exception import ConnectionError
from slapos.slap.slap import NotFoundError from slapos.slap.slap import NotFoundError
from slapos.slap.slap import ServerError from slapos.slap.slap import ServerError
from slapos.slap.slap import COMPUTER_PARTITION_REQUEST_LIST_TEMPLATE_FILENAME from slapos.slap.slap import COMPUTER_PARTITION_REQUEST_LIST_TEMPLATE_FILENAME
...@@ -1425,7 +1426,7 @@ stderr_logfile_backups=1 ...@@ -1425,7 +1426,7 @@ stderr_logfile_backups=1
def processComputerPartitionList(self): def processComputerPartitionList(self):
try: try:
return self.processComputerPartitionListOnline() return self.processComputerPartitionListOnline()
except RequestException: except (RequestException, ConnectionError):
return self.processComputerPartitionListOffline() return self.processComputerPartitionListOffline()
def processComputerPartitionListOnline(self): def processComputerPartitionListOnline(self):
...@@ -1456,7 +1457,7 @@ stderr_logfile_backups=1 ...@@ -1456,7 +1457,7 @@ stderr_logfile_backups=1
self.processComputerPartition(computer_partition) self.processComputerPartition(computer_partition)
# Handle connection loss at the next level # Handle connection loss at the next level
except RequestException: except (RequestException, ConnectionError):
raise raise
# Send log before exiting # Send log before exiting
......
...@@ -308,7 +308,9 @@ class TestBasicSlapgridCP(BasicMixin, unittest.TestCase): ...@@ -308,7 +308,9 @@ class TestBasicSlapgridCP(BasicMixin, unittest.TestCase):
def test_no_master(self): def test_no_master(self):
os.mkdir(self.software_root) os.mkdir(self.software_root)
os.mkdir(self.instance_root) os.mkdir(self.instance_root)
self.assertRaises(ConnectionError, self.grid.processComputerPartitionList) self.assertEqual(
self.grid.processComputerPartitionList(),
slapgrid.SLAPGRID_OFFLINE_SUCCESS)
def test_environment_variable_HOME(self): def test_environment_variable_HOME(self):
# When running instance, $HOME is set to the partition path # When running instance, $HOME is set to the partition path
......
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