Return 404 if not enough ready in pool
This changes the behavior to prevent locking a node that does not match the requested pool. Currently using a pool locks a node in that pool if there is one ready, as expected. If there is not one ready from the pool but there is any other node ready, it will lock a node outside the pool, not expected and breaking behavior. Change-Id: I285256037e16f94c79cc7d813235460b4032393d
This commit is contained in:
parent
5cf167d567
commit
ca5ec06b40
|
@ -507,6 +507,11 @@ class DataBase(object):
|
|||
if node_pool != "Default":
|
||||
count_with_pool = session.query(Nodes).filter_by(
|
||||
status="ready", node_pool=node_pool).count()
|
||||
if count_with_pool < how_many:
|
||||
fmt = "Not enough available nodes found."
|
||||
fmt += " Found %d, requested %d"
|
||||
return {'status': 404,
|
||||
'message': fmt % (count_with_pool, how_many, )}
|
||||
# If we don't have enough nodes return an error
|
||||
if count < how_many:
|
||||
fmt = "Not enough available nodes found."
|
||||
|
|
Loading…
Reference in New Issue