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): def pop(self, db: Application):
mapper = self.get_mapper() 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) mapper.pop(to_delete_port, None)
self.set_mapper(mapper) 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() mapper = self.get_mapper()
for port, db_id in mapper.items(): for port, db_id in mapper.items():
if db_id == str(db.id): if db_id == str(db.id):
return port return port
error = _( if raise_exception:
'No available port is matched. ' error = _(
'The number of databases may have exceeded the number of ports ' 'No available port is matched. '
'open to the database agent service, ' 'The number of databases may have exceeded the number of ports '
'Contact the administrator to open more ports.' 'open to the database agent service, '
) 'Contact the administrator to open more ports.'
raise JMSException(error) )
raise JMSException(error)
def get_db_by_port(self, port): def get_db_by_port(self, port):
try: try:

Loading…
Cancel
Save