Browse Source

add comments describing how to correct async creates / handle fails

master
forest 3 months ago
parent
commit
5a18fc7e13
3 changed files with 9 additions and 1 deletions
  1. +1
    -1
      capsulflask/db.py
  2. +4
    -0
      capsulflask/hub_api.py
  3. +4
    -0
      capsulflask/spoke_api.py

+ 1
- 1
capsulflask/db.py 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:
connection = current_app.config['PSYCOPG2_CONNECTION_POOL'].getconn()
cursor = connection.cursor()


+ 4
- 0
capsulflask/hub_api.py View File

@ -169,6 +169,10 @@ def can_claim_create(payload, host_id) -> (str, str):
return payload, ""
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(
email=payload['email'],
id=payload['id'],


+ 4
- 0
capsulflask/spoke_api.py 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")
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:
current_app.config['SPOKE_MODEL'].create(
email=request_body['email'],


Loading…
Cancel
Save