Skip to content

Commit

Permalink
NAS-129862 / 24.10 / fix failover.mismatch_nics (#13962)
Browse files Browse the repository at this point in the history
* fix failover.mismatch_nics

* address review
  • Loading branch information
yocalebo authored Jul 2, 2024
1 parent 7714865 commit 606061e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
15 changes: 11 additions & 4 deletions src/middlewared/middlewared/plugins/failover.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,17 +439,24 @@ async def get_disks_local(self):
async def mismatch_nics(self):
"""Determine if NICs match between both controllers."""
result = {'missing_local': list(), 'missing_remote': list()}
local_nics = await self.middleware.call('interface.get_nic_names') or set()
try:
local_nics = await self.middleware.call('interface.get_nic_names')
except Exception:
self.logger.error('Unhandled exception in get_nic_names on local controller', exc_info=True)
return result

try:
remote_nics = await self.middleware.call(
'failover.call_remote', 'interface.get_nic_names', [],
{'raise_connect_error': False, 'timeout': 2, 'connect_timeout': 2}
) or set()
)
except Exception:
self.logger.error('Unhandled exception in get_nic_names on remote controller', exc_info=True)
else:
result['missing_local'] = sorted(remote_nics - local_nics)
result['missing_remote'] = sorted(local_nics - remote_nics)
if remote_nics is not None:
result['missing_local'] = sorted(remote_nics - local_nics)
result['missing_remote'] = sorted(local_nics - remote_nics)

return result

@private
Expand Down
8 changes: 5 additions & 3 deletions src/middlewared/middlewared/plugins/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1916,10 +1916,12 @@ def ip_in_use(self, choices):
@private
def get_nic_names(self) -> set:
"""Get network interface names excluding internal interfaces"""
res, ignore = set(), set(self.middleware.call_sync('interface.internal_interfaces'))
with scandir('/sys/class/net/') as nics:
res = set(nic.name for nic in nics)
ignore = set(self.middleware.call_sync('interface.internal_interfaces'))
return res - ignore
for nic in filter(lambda x: x.is_symlink() and x.name not in ignore, nics):
res.add(nic.name)

return res


async def configure_http_proxy(middleware, *args, **kwargs):
Expand Down

0 comments on commit 606061e

Please sign in to comment.