perf: After optimizing the execution of the azure vault task, the data is out of sync

pull/14555/head
halo 2024-11-26 09:50:17 +08:00 committed by feng626
parent d0617a0ea4
commit 801edc7cc9
3 changed files with 2 additions and 5 deletions

View File

@ -13,9 +13,6 @@ logger = get_logger(__file__)
def get_vault_client(raise_exception=False, **kwargs):
tp = kwargs.get('VAULT_BACKEND') if kwargs.get('VAULT_ENABLED') else VaultTypeChoices.local
# TODO: Temporary processing, subsequent deletion
tp = VaultTypeChoices.local if tp == VaultTypeChoices.azure else tp
try:
module_path = f'apps.accounts.backends.{tp}.main'
client = import_module(module_path).Vault(**kwargs)

View File

@ -36,7 +36,6 @@ class AZUREVaultClient(object):
secret = self.client.get_secret(name, version)
return secret.value
except (ResourceNotFoundError, ClientAuthenticationError) as e:
logger.error(f'get: {name} {str(e)}')
return ''
def create(self, name, secret):

View File

@ -52,7 +52,8 @@ def sync_secret_to_vault():
for model in to_sync_models:
instances += list(model.objects.all())
with ThreadPoolExecutor(max_workers=10) as executor:
max_workers = 1 if VaultTypeChoices.azure == vault_client.type else max_workers = 10
with ThreadPoolExecutor(max_workers=max_workers) as executor:
tasks = [executor.submit(sync_instance, instance) for instance in instances]
for future in as_completed(tasks):