Skip to content

Commit

Permalink
Enhance server lock documentation and improve port connectivity handl…
Browse files Browse the repository at this point in the history
…ing in IPMachinesService
  • Loading branch information
dkmstr committed Feb 19, 2025
1 parent 2c2c6d5 commit 3efeeb4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
11 changes: 10 additions & 1 deletion server/src/uds/models/servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,16 @@ def stats(self, value: typing.Optional[types.servers.ServerStats]) -> None:
self.properties['stats'] = stats_dict

def lock(self, duration: typing.Optional[datetime.timedelta]) -> None:
"""Locks this server for a duration"""
"""Locks this server for a duration
Args:
duration: Duration to lock the server. If None, it will be unlocked
Note:
If duration is None, the server will be unlocked
The lock time will be calculated from current time on sql server
"""

if duration is None:
self.locked_until = None
else:
Expand Down
13 changes: 2 additions & 11 deletions server/src/uds/services/PhysicalMachines/service_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,10 @@ def get_unassigned(self) -> str:
for server in list_of_servers:
# If not locked or lock expired
if server.locked_until is None or server.locked_until < sql_now():
# if port check enabled, check
# if port check enabled, check
if self.port.value != 0:
# if we have a cache entry, and it's not None, it's because it failed the check
# not too long ago, so we skip it
if self.cache.get(f'port{server.host}'):
continue

if not net.test_connectivity(server.host, self.port.value):
self.cache.put(
f'port{server.host}',
'failed',
self.ignore_minutes_on_failure.value * 60,
)
server.lock(datetime.timedelta(minutes=self.ignore_minutes_on_failure.value))
self.provider().do_log(
types.log.LogLevel.WARNING,
f'Host {server.host} does not respond to port {self.port.value}, skipping',
Expand Down

0 comments on commit 3efeeb4

Please sign in to comment.