Do not proceed with introspection on a node twice
Change-Id: Icd80b5f0ee1b9b893d1d2b7a782c7317d76834d5 Closes-Bug: #1408986
This commit is contained in:
parent
79a9fae6ca
commit
c23b05b4b8
|
@ -180,14 +180,19 @@ def find_node(**attributes):
|
|||
raise utils.DiscoveryFailed('Multiple matching nodes found', code=404)
|
||||
|
||||
uuid = found.pop()
|
||||
row = (db.execute('select started_at from nodes where uuid=?', (uuid,))
|
||||
.fetchone())
|
||||
row = db.execute('select started_at, finished_at from nodes where uuid=?',
|
||||
(uuid,)).fetchone()
|
||||
if not row:
|
||||
LOG.error('Inconsistent database: %s is in attributes table, '
|
||||
'but not in nodes table', uuid)
|
||||
raise utils.DiscoveryFailed('Could not find a node', code=404)
|
||||
|
||||
return NodeInfo(uuid=uuid, started_at=row[0])
|
||||
if row['finished_at']:
|
||||
LOG.error('Discovery for node %s finished on %s already',
|
||||
uuid, row['finished_at'])
|
||||
raise utils.DiscoveryFailed('Discovery for node %s already finished')
|
||||
|
||||
return NodeInfo(uuid=uuid, started_at=row['started_at'])
|
||||
|
||||
|
||||
def clean_up():
|
||||
|
|
|
@ -73,9 +73,9 @@ class TestNodeCache(test_base.NodeTest):
|
|||
node_cache.macs_on_discovery())
|
||||
|
||||
|
||||
class TestNodeCachePop(test_base.NodeTest):
|
||||
class TestNodeCacheFind(test_base.NodeTest):
|
||||
def setUp(self):
|
||||
super(TestNodeCachePop, self).setUp()
|
||||
super(TestNodeCacheFind, self).setUp()
|
||||
self.macs2 = ['00:00:00:00:00:00']
|
||||
node_cache.add_node(self.uuid,
|
||||
bmc_address='1.2.3.4',
|
||||
|
@ -117,6 +117,13 @@ class TestNodeCachePop(test_base.NodeTest):
|
|||
self.assertRaises(utils.DiscoveryFailed, node_cache.find_node,
|
||||
bmc_address='1.2.3.4')
|
||||
|
||||
def test_already_finished(self):
|
||||
with self.db:
|
||||
self.db.execute('update nodes set finished_at=42.0 where uuid=?',
|
||||
(self.uuid,))
|
||||
self.assertRaises(utils.DiscoveryFailed, node_cache.find_node,
|
||||
bmc_address='1.2.3.4')
|
||||
|
||||
|
||||
class TestNodeCacheCleanUp(test_base.NodeTest):
|
||||
def setUp(self):
|
||||
|
|
Loading…
Reference in New Issue