mirror of https://github.com/jumpserver/jumpserver
perf: safe db connection on runner success
parent
9e857b54ed
commit
dfa0198742
|
@ -11,6 +11,7 @@ from django.utils.translation import gettext as _
|
||||||
from sshtunnel import SSHTunnelForwarder
|
from sshtunnel import SSHTunnelForwarder
|
||||||
|
|
||||||
from assets.automations.methods import platform_automation_methods
|
from assets.automations.methods import platform_automation_methods
|
||||||
|
from common.db.utils import safe_db_connection
|
||||||
from common.utils import get_logger, lazyproperty, is_openssh_format_key, ssh_pubkey_gen
|
from common.utils import get_logger, lazyproperty, is_openssh_format_key, ssh_pubkey_gen
|
||||||
from ops.ansible import JMSInventory, DefaultCallback, SuperPlaybookRunner
|
from ops.ansible import JMSInventory, DefaultCallback, SuperPlaybookRunner
|
||||||
from ops.ansible.interface import interface
|
from ops.ansible.interface import interface
|
||||||
|
@ -339,7 +340,8 @@ class BasePlaybookManager:
|
||||||
try:
|
try:
|
||||||
kwargs.update({"clean_workspace": False})
|
kwargs.update({"clean_workspace": False})
|
||||||
cb = runner.run(**kwargs)
|
cb = runner.run(**kwargs)
|
||||||
self.on_runner_success(runner, cb)
|
with safe_db_connection():
|
||||||
|
self.on_runner_success(runner, cb)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.on_runner_failed(runner, e)
|
self.on_runner_failed(runner, e)
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Reference in New Issue