mirror of https://github.com/jumpserver/jumpserver
perf: After optimizing the execution of the azure vault task, the data is out of sync
parent
d0617a0ea4
commit
801edc7cc9
|
@ -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)
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue