Browse Source

fix: 修复删除数据库由于端口数量限制导致不能删除的问题

pull/9080/head
Jiangjie.Bai 2 years ago
parent
commit
a2b9a5cee3
  1. 19
      apps/terminal/utils/db_port_mapper.py

19
apps/terminal/utils/db_port_mapper.py

@ -51,22 +51,23 @@ class DBPortManager(object):
def pop(self, db: Application):
mapper = self.get_mapper()
to_delete_port = self.get_port_by_db(db)
to_delete_port = self.get_port_by_db(db, raise_exception=False)
mapper.pop(to_delete_port, None)
self.set_mapper(mapper)
def get_port_by_db(self, db):
def get_port_by_db(self, db, raise_exception=True):
mapper = self.get_mapper()
for port, db_id in mapper.items():
if db_id == str(db.id):
return port
error = _(
'No available port is matched. '
'The number of databases may have exceeded the number of ports '
'open to the database agent service, '
'Contact the administrator to open more ports.'
)
raise JMSException(error)
if raise_exception:
error = _(
'No available port is matched. '
'The number of databases may have exceeded the number of ports '
'open to the database agent service, '
'Contact the administrator to open more ports.'
)
raise JMSException(error)
def get_db_by_port(self, port):
try:

Loading…
Cancel
Save