Fixes 'sys.exit() doesn't do what you think it does'
Two problems here: 1. is_online() was testing the wrong thing so was always True 2. sys.exit() actually throws exceptions on threads which are not the thread that made the call. If you have a catchall except statement this will also catch the exit signal. So the application never exits. In the pool manager's case the signal handler is running on a separate thread. The signal handler thread executes sys.exit() and if the main thread is in a block with a catchall except it hangs. Fixed this by narrowing the exception list caught. Fixes bug #1078738 Change-Id: I9f561b9d3794d1f6fab84c116f69e7fe97464e85
This commit is contained in:
@@ -50,7 +50,7 @@ class HPRestDriver(MgmDriver):
|
||||
return usage['free']
|
||||
|
||||
def is_online(self):
|
||||
return self.is_online
|
||||
return self.online
|
||||
|
||||
def get_node_list(self, limit, marker):
|
||||
return self._get('{url}/devices'.format(url=self.url))
|
||||
@@ -80,7 +80,7 @@ class HPRestDriver(MgmDriver):
|
||||
def _get(self, url):
|
||||
try:
|
||||
r = requests.get(url, verify=False)
|
||||
except:
|
||||
except requests.exceptions.RequestException:
|
||||
self.logger.error('Exception communicating to server: {exc}'
|
||||
.format(exc=sys.exc_info()[0]))
|
||||
return False, None
|
||||
@@ -94,7 +94,7 @@ class HPRestDriver(MgmDriver):
|
||||
def _post(self, url, node_data):
|
||||
try:
|
||||
r = requests.post(url, data=json.dumps(node_data), verify=False)
|
||||
except:
|
||||
except requests.exceptions.RequestException:
|
||||
self.logger.error('Exception communicating to server: {exc}'
|
||||
.format(exc=sys.exc_info()[0]))
|
||||
return False, None
|
||||
|
||||
@@ -18,6 +18,7 @@ import sys
|
||||
import urllib
|
||||
|
||||
from novaclient import client
|
||||
from novaclient import exceptions
|
||||
|
||||
|
||||
class NotFound(Exception):
|
||||
@@ -52,7 +53,7 @@ class Node(object):
|
||||
node_id = uuid.uuid1()
|
||||
try:
|
||||
body = self._create(node_id)
|
||||
except:
|
||||
except exceptions.ClientException:
|
||||
return False, 'Error creating node {nid} exception {exc}'.format(
|
||||
nid=node_id, exc=sys.exc_info()[0]
|
||||
)
|
||||
@@ -80,7 +81,7 @@ class Node(object):
|
||||
""" delete a node """
|
||||
try:
|
||||
resp = self._delete(node_id)
|
||||
except:
|
||||
except exceptions.ClientException:
|
||||
return False, 'Error deleting node {nid} exception {exc}'.format(
|
||||
nid=node_id, exc=sys.exc_info()[0]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user