fix: 修复创建 Oracle 数据库端口超过范围后报错 500 并且不回滚的问题;

pull/11028/head
Bai 2023-07-20 11:22:08 +08:00 committed by Bryan
parent 2291cfeaae
commit ffb400d70d
1 changed files with 5 additions and 6 deletions

View File

@ -1,7 +1,7 @@
from django.db.models.signals import post_delete, post_save from django.db.models.signals import post_delete, post_save
from django.dispatch import receiver from django.dispatch import receiver
from assets.models import Asset from assets.models import Asset, Database
from common.decorators import on_transaction_commit from common.decorators import on_transaction_commit
from common.signals import django_ready from common.signals import django_ready
from common.utils import get_logger from common.utils import get_logger
@ -12,16 +12,15 @@ logger = get_logger(__file__)
@receiver(django_ready) @receiver(django_ready)
def check_db_port_mapper(sender, **kwargs): def check_db_port_mapper(sender, **kwargs):
logger.info('Check oracle ports') logger.info('Check oracle ports (MAGNUS_ORACLE_PORTS)')
try: try:
db_port_manager.check() db_port_manager.check()
except Exception as e: except Exception as e:
pass logger.error(e)
@receiver(post_save, sender=Asset) @receiver(post_save, sender=Database)
@on_transaction_commit def on_db_created(sender, instance: Database, created, **kwargs):
def on_db_created(sender, instance: Asset, created, **kwargs):
if instance.type != 'oracle': if instance.type != 'oracle':
return return
if not created: if not created: