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. Also update to handle PyYAML 6.0.0 Change-Id: I285256037e16f94c79cc7d813235460b4032393d
This commit is contained in:
parent
5cf167d567
commit
0e2f2a987b
@ -83,7 +83,7 @@ if __name__ == "__main__":
|
|||||||
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
||||||
|
|
||||||
with open(YAML_CONF, "r") as fobj:
|
with open(YAML_CONF, "r") as fobj:
|
||||||
conf = yaml.load(fobj)
|
conf = yaml.load(fobj, Loader=yaml.SafeLoader)
|
||||||
|
|
||||||
mi.setup_conf(conf)
|
mi.setup_conf(conf)
|
||||||
mi.setup_parser(parser)
|
mi.setup_parser(parser)
|
||||||
|
@ -77,7 +77,7 @@ def moltenirond_main():
|
|||||||
"""This is the main routine for the MoltenIron server."""
|
"""This is the main routine for the MoltenIron server."""
|
||||||
|
|
||||||
with open(YAML_CONF, "r") as fobj:
|
with open(YAML_CONF, "r") as fobj:
|
||||||
conf = yaml.load(fobj)
|
conf = yaml.load(fobj, Loader=yaml.SafeLoader)
|
||||||
|
|
||||||
moltenirond.listener(conf)
|
moltenirond.listener(conf)
|
||||||
|
|
||||||
|
@ -507,6 +507,11 @@ class DataBase(object):
|
|||||||
if node_pool != "Default":
|
if node_pool != "Default":
|
||||||
count_with_pool = session.query(Nodes).filter_by(
|
count_with_pool = session.query(Nodes).filter_by(
|
||||||
status="ready", node_pool=node_pool).count()
|
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 we don't have enough nodes return an error
|
||||||
if count < how_many:
|
if count < how_many:
|
||||||
fmt = "Not enough available nodes found."
|
fmt = "Not enough available nodes found."
|
||||||
@ -1357,6 +1362,6 @@ if __name__ == "__main__":
|
|||||||
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
||||||
|
|
||||||
with open(YAML_CONF, "r") as fobj:
|
with open(YAML_CONF, "r") as fobj:
|
||||||
conf = yaml.load(fobj)
|
conf = yaml.load(fobj, Loader=yaml.SafeLoader)
|
||||||
|
|
||||||
listener(conf)
|
listener(conf)
|
||||||
|
@ -53,7 +53,7 @@ if __name__ == "__main__":
|
|||||||
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
||||||
|
|
||||||
with open(YAML_CONF, "r") as fobj:
|
with open(YAML_CONF, "r") as fobj:
|
||||||
conf = yaml.load(fobj)
|
conf = yaml.load(fobj, Loader=yaml.SafeLoader)
|
||||||
|
|
||||||
request1 = {
|
request1 = {
|
||||||
"name": "pkvmci816",
|
"name": "pkvmci816",
|
||||||
|
@ -94,7 +94,7 @@ if __name__ == "__main__":
|
|||||||
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
||||||
|
|
||||||
with open(YAML_CONF, "r") as fobj:
|
with open(YAML_CONF, "r") as fobj:
|
||||||
conf = yaml.load(fobj)
|
conf = yaml.load(fobj, Loader=yaml.SafeLoader)
|
||||||
|
|
||||||
request1 = {
|
request1 = {
|
||||||
"name": "pkvmci816",
|
"name": "pkvmci816",
|
||||||
|
@ -93,7 +93,7 @@ if __name__ == "__main__":
|
|||||||
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
||||||
|
|
||||||
with open(YAML_CONF, "r") as fobj:
|
with open(YAML_CONF, "r") as fobj:
|
||||||
conf = yaml.load(fobj)
|
conf = yaml.load(fobj, Loader=yaml.SafeLoader)
|
||||||
|
|
||||||
request1 = {
|
request1 = {
|
||||||
"name": "pkvmci816",
|
"name": "pkvmci816",
|
||||||
|
@ -94,7 +94,7 @@ if __name__ == "__main__":
|
|||||||
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
||||||
|
|
||||||
with open(YAML_CONF, "r") as fobj:
|
with open(YAML_CONF, "r") as fobj:
|
||||||
conf = yaml.load(fobj)
|
conf = yaml.load(fobj, Loader=yaml.SafeLoader)
|
||||||
|
|
||||||
request1 = {
|
request1 = {
|
||||||
"name": "pkvmci816",
|
"name": "pkvmci816",
|
||||||
|
@ -94,7 +94,7 @@ if __name__ == "__main__":
|
|||||||
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
||||||
|
|
||||||
with open(YAML_CONF, "r") as fobj:
|
with open(YAML_CONF, "r") as fobj:
|
||||||
conf = yaml.load(fobj)
|
conf = yaml.load(fobj, Loader=yaml.SafeLoader)
|
||||||
|
|
||||||
request1 = {
|
request1 = {
|
||||||
"name": "pkvmci816",
|
"name": "pkvmci816",
|
||||||
|
@ -53,7 +53,7 @@ if __name__ == "__main__":
|
|||||||
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
||||||
|
|
||||||
with open(YAML_CONF, "r") as fobj:
|
with open(YAML_CONF, "r") as fobj:
|
||||||
conf = yaml.load(fobj)
|
conf = yaml.load(fobj, Loader=yaml.SafeLoader)
|
||||||
|
|
||||||
request1 = {
|
request1 = {
|
||||||
"name": "pkvmci816",
|
"name": "pkvmci816",
|
||||||
|
@ -53,7 +53,7 @@ if __name__ == "__main__":
|
|||||||
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
||||||
|
|
||||||
with open(YAML_CONF, "r") as fobj:
|
with open(YAML_CONF, "r") as fobj:
|
||||||
conf = yaml.load(fobj)
|
conf = yaml.load(fobj, Loader=yaml.SafeLoader)
|
||||||
|
|
||||||
request1 = {
|
request1 = {
|
||||||
"name": "pkvmci816",
|
"name": "pkvmci816",
|
||||||
|
@ -53,7 +53,7 @@ if __name__ == "__main__":
|
|||||||
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
||||||
|
|
||||||
with open(YAML_CONF, "r") as fobj:
|
with open(YAML_CONF, "r") as fobj:
|
||||||
conf = yaml.load(fobj)
|
conf = yaml.load(fobj, Loader=yaml.SafeLoader)
|
||||||
|
|
||||||
request1 = {
|
request1 = {
|
||||||
"name": "pkvmci816",
|
"name": "pkvmci816",
|
||||||
|
@ -53,7 +53,7 @@ if __name__ == "__main__":
|
|||||||
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
||||||
|
|
||||||
with open(YAML_CONF, "r") as fobj:
|
with open(YAML_CONF, "r") as fobj:
|
||||||
conf = yaml.load(fobj)
|
conf = yaml.load(fobj, Loader=yaml.SafeLoader)
|
||||||
|
|
||||||
request1 = {
|
request1 = {
|
||||||
"name": "pkvmci816",
|
"name": "pkvmci816",
|
||||||
|
@ -40,7 +40,7 @@ def main():
|
|||||||
# The conf.yaml is located in the molteniron/ directory.
|
# The conf.yaml is located in the molteniron/ directory.
|
||||||
newPath = "/".join(dirs[:-2]) + "/"
|
newPath = "/".join(dirs[:-2]) + "/"
|
||||||
fobj = open(newPath + "molteniron/conf.yaml", "r")
|
fobj = open(newPath + "molteniron/conf.yaml", "r")
|
||||||
conf = yaml.load(fobj)
|
conf = yaml.load(fobj, Loader=yaml.SafeLoader)
|
||||||
|
|
||||||
# Create the SQL User
|
# Create the SQL User
|
||||||
SQL("CREATE USER '"
|
SQL("CREATE USER '"
|
||||||
|
@ -83,7 +83,7 @@ if __name__ == "__main__":
|
|||||||
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
YAML_CONF = resource_filename("molteniron", "conf.yaml")
|
||||||
|
|
||||||
with open(YAML_CONF, "r") as fobj:
|
with open(YAML_CONF, "r") as fobj:
|
||||||
conf = yaml.load(fobj)
|
conf = yaml.load(fobj, Loader=yaml.SafeLoader)
|
||||||
|
|
||||||
mi.setup_conf(conf)
|
mi.setup_conf(conf)
|
||||||
mi.setup_parser(parser)
|
mi.setup_parser(parser)
|
||||||
|
Loading…
Reference in New Issue
Block a user