fix: If the cloud vault initialization fails, the task will not be executed.

pull/14480/head
halo 5 days ago
parent b6a5854fa2
commit 8357c509e9

@ -5,6 +5,7 @@ from celery import shared_task
from django.utils.translation import gettext_lazy as _
from accounts.backends import vault_client
from accounts.const import VaultTypeChoices
from accounts.models import Account, AccountTemplate
from common.utils import get_logger
from orgs.utils import tmp_to_root_org
@ -40,6 +41,10 @@ def sync_secret_to_vault():
print('\033[35m>>> 当前 Vault 功能未开启, 不需要同步')
return
if VaultTypeChoices.local in str(vault_client.__class__):
print('\033[35m>>> 当前 Vault 客户端初始化失败,数据存储在本地数据库')
return
failed, skipped, succeeded = 0, 0, 0
to_sync_models = [Account, AccountTemplate, Account.history.model]
print(f'\033[33m>>> 开始同步密钥数据到 Vault ({datetime.now().strftime("%Y-%m-%d %H:%M:%S")})')

Loading…
Cancel
Save