Merge pull request #8023 from velzend/improve_logging_migrating_or_instance_not_registered

improve logging migrate or instance not registered
This commit is contained in:
Shane McDonald
2021-07-22 15:50:33 -04:00
committed by GitHub

View File

@@ -97,16 +97,7 @@ class Command(BaseCommand):
executor = MigrationExecutor(connection) executor = MigrationExecutor(connection)
migrating = bool(executor.migration_plan(executor.loader.graph.leaf_nodes())) migrating = bool(executor.migration_plan(executor.loader.graph.leaf_nodes()))
registered = False
if not migrating:
try:
Instance.objects.me()
registered = True
except RuntimeError:
pass
if migrating or not registered:
# In containerized deployments, migrations happen in the task container, # In containerized deployments, migrations happen in the task container,
# and the services running there don't start until migrations are # and the services running there don't start until migrations are
# finished. # finished.
@@ -117,7 +108,18 @@ class Command(BaseCommand):
# where migrations aren't yet finished (similar to the migration # where migrations aren't yet finished (similar to the migration
# detection middleware that the uwsgi processes have) or when instance # detection middleware that the uwsgi processes have) or when instance
# registration isn't done yet # registration isn't done yet
logger.error('AWX is currently installing/upgrading. Trying again in 5s...') if migrating:
logger.info('AWX is currently migrating, retry in 10s...')
time.sleep(10)
return
try:
me = Instance.objects.me()
logger.info('Active instance with hostname {} is registered.'.format(me.hostname))
except RuntimeError as e:
# the CLUSTER_HOST_ID in the task, and web instance must match and
# ensure network connectivity between the task and web instance
logger.info('Unable to return currently active instance: {}, retry in 5s...'.format(e))
time.sleep(5) time.sleep(5)
return return