fix startup migration fail with unavailable shards

This commit is contained in:
simon 2023-03-04 18:10:18 +07:00
parent ee568534f6
commit 22ef33c6ca
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
1 changed files with 7 additions and 0 deletions

View File

@ -4,6 +4,7 @@ Functionality:
- Apply migrations
"""
from time import sleep
import os
from django.core.management.base import BaseCommand, CommandError
@ -151,6 +152,12 @@ class Command(BaseCommand):
for index_name in index_list:
path = f"{index_name}/_update_by_query"
response, status_code = ElasticWrap(path).post(data=data)
if status_code == 503:
message = f" 🗙 {index_name} retry failed migration."
self.stdout.write(self.style.ERROR(message))
sleep(10)
response, status_code = ElasticWrap(path).post(data=data)
if status_code == 200:
updated = response.get("updated", 0)
if not updated: