diff --git a/backend/config/management/commands/ta_connection.py b/backend/config/management/commands/ta_connection.py index 3edb42db..4ad511d1 100644 --- a/backend/config/management/commands/ta_connection.py +++ b/backend/config/management/commands/ta_connection.py @@ -99,7 +99,12 @@ class Command(BaseCommand): continue if status_code and status_code == 200: - path = "_cluster/health?wait_for_status=yellow&timeout=60s" + path = ( + "_cluster/health?" + "wait_for_status=yellow&" + "timeout=60s&" + "wait_for_active_shards=1" + ) _, _ = ElasticWrap(path).get(timeout=60) self.stdout.write( self.style.SUCCESS(" ✓ ES connection established") diff --git a/backend/config/management/commands/ta_startup.py b/backend/config/management/commands/ta_startup.py index e80af6b7..980354b1 100644 --- a/backend/config/management/commands/ta_startup.py +++ b/backend/config/management/commands/ta_startup.py @@ -263,7 +263,7 @@ class Command(BaseCommand): def _init_app_config(self) -> None: """init default app config to ES""" self.stdout.write("[10] Check AppConfig") - _, status_code = ElasticWrap("ta_config/_doc/appsettings").get() + response, status_code = ElasticWrap("ta_config/_doc/appsettings").get() if status_code in [200, 201]: self.stdout.write( self.style.SUCCESS(" skip completed appsettings init") @@ -276,6 +276,13 @@ class Command(BaseCommand): return + if status_code != 404: + message = " 🗙 ta_config index lookup failed" + self.stdout.write(self.style.ERROR(message)) + self.stdout.write(response) + sleep(60) + raise CommandError(message) + handler = AppConfig.__new__(AppConfig) _, status_code = handler.sync_defaults() self.stdout.write(