Closed bzwei closed 1 month ago
I think we should not take care of any logic to wait_for and just check if we are running migrations and otherwise fail. As it is a external command, such a logic should be handled externally.
Also, as alternative to catch the exception, we could just look if the migrations are already applied
from django.db.migrations.executor import MigrationExecutor
from django.db import connection
executor = MigrationExecutor(connection)
targets = executor.loader.graph.leaf_nodes()
plan = executor.migration_plan(targets)
# there are pending migrations...
if plan:
@Alex-Izquierdo This is a good idea. It requires we update the startup command for all related pods (worker, scheduler), right?
@Alex-Izquierdo This is a good idea. It requires we update the startup command for all related pods (worker, scheduler), right?
Yes, in the docker-compose there is no need, because the compose file itself handles the dependency on the api pod. I'm talking with @rooftopcellist so he can use that command in the operator.
In this PR, I would say we don't need to apply any "wait for" logic, just detect if we run migrations commands.
@Alex-Izquierdo I updated the PR. This PR does not detect whether a migration has completed because it does not need to wait for all migrations be done every time. No error is raised as long as the service_id can be fetched, which is populated the first time.
Scheduler and workers automatically wait on the service_id being ready so that we don't rely on the installer or operator to maintain the start-up dependency. Do not wait if the startup is for migration
Update: Based on the discussion, this PR now only raise an error if the process is running as a server, a scheduler, or a worker. It does not wait on possible migration done by another process.