ansible / eda-server

Event Driven Ansible for AAP
Apache License 2.0
59 stars 35 forks source link

fix: raise an error if service_id is not ready #926

Closed bzwei closed 1 month ago

bzwei commented 1 month ago

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.

Alex-Izquierdo commented 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 commented 1 month ago

Look at https://github.com/ansible/eda-server/pull/927

bzwei commented 1 month ago

@Alex-Izquierdo This is a good idea. It requires we update the startup command for all related pods (worker, scheduler), right?

Alex-Izquierdo commented 1 month ago

@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.

Alex-Izquierdo commented 1 month ago

In this PR, I would say we don't need to apply any "wait for" logic, just detect if we run migrations commands.

bzwei commented 1 month ago

@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.