Skip to content

Commit

Permalink
Fix: Changes DB initialization order to ensure that DB always exists …
Browse files Browse the repository at this point in the history
…before running the migrations.
  • Loading branch information
nesitor committed Dec 11, 2024
1 parent 7c78202 commit 7303587
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/aleph/vm/orchestrator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ async def benchmark(runs: int):
"""Measure program performance by immediately running the supervisor
with fake requests.
"""
engine = metrics.setup_engine()
await metrics.create_tables(engine)

ref = ItemHash("cafecafecafecafecafecafecafecafecafecafecafecafecafecafecafecafe")
settings.FAKE_DATA_PROGRAM = settings.BENCHMARK_FAKE_DATA_PROGRAM

Expand Down Expand Up @@ -357,6 +354,10 @@ def main():
settings.check()

logger.debug("Initialising the DB...")
# Check and create execution database
engine = metrics.setup_engine()
asyncio.run(metrics.create_tables(engine))

Check warning on line 359 in src/aleph/vm/orchestrator/cli.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/orchestrator/cli.py#L358-L359

Added lines #L358 - L359 were not covered by tests
# After creating it run the DB migrations
asyncio.run(run_async_db_migrations())
logger.debug("DB up to date.")

Expand Down
4 changes: 0 additions & 4 deletions src/aleph/vm/orchestrator/supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from aleph.vm.sevclient import SevClient
from aleph.vm.version import __version__

from .metrics import create_tables, setup_engine
from .resources import about_certificates, about_system_usage
from .tasks import (
start_payment_monitoring_task,
Expand Down Expand Up @@ -151,9 +150,6 @@ def run():
"""Run the VM Supervisor."""
settings.check()

engine = setup_engine()
asyncio.run(create_tables(engine))

loop = asyncio.new_event_loop()
pool = VmPool(loop)
pool.setup()
Expand Down

0 comments on commit 7303587

Please sign in to comment.