add comments describing how to correct async creates / handle fails

This commit is contained in:
forest 2021-09-02 12:34:51 -05:00
parent 5a67a58f98
commit 5a18fc7e13
3 changed files with 9 additions and 1 deletions

View File

@ -114,7 +114,7 @@ def init_app(app, is_running_server):
def get_model(): def get_model() -> DBModel:
if 'db_model' not in g: if 'db_model' not in g:
connection = current_app.config['PSYCOPG2_CONNECTION_POOL'].getconn() connection = current_app.config['PSYCOPG2_CONNECTION_POOL'].getconn()
cursor = connection.cursor() cursor = connection.cursor()

View File

@ -169,6 +169,10 @@ def can_claim_create(payload, host_id) -> (str, str):
return payload, "" return payload, ""
def on_create_claimed(payload, host_id): def on_create_claimed(payload, host_id):
# TODO this happens when the create operation is assigned to one spoke, not when the create actually succeeds...
# VMs should probably start out in the "creating" state, and change to "booting" when the create.sh script succeeds.
# VMs should not be billable until they reach the booting state.
# see the corresponding TODO in spoke_api.handle_create
get_model().create_vm( get_model().create_vm(
email=payload['email'], email=payload['email'],
id=payload['id'], id=payload['id'],

View File

@ -144,6 +144,10 @@ def handle_create(operation_id, request_body):
return abort(503, f"hub did not cleanly handle our request to claim the create operation") return abort(503, f"hub did not cleanly handle our request to claim the create operation")
if assignment_status == "assigned": if assignment_status == "assigned":
# TODO this should probably be spun off as a coroutine
# and at the end of that coroutine, we should set the VM's state from "creating" to "booting"
# see the corresponding TODO in hub_api.on_create_claimed
try: try:
current_app.config['SPOKE_MODEL'].create( current_app.config['SPOKE_MODEL'].create(
email=request_body['email'], email=request_body['email'],