From 613348ec90e41e3e403fe4566bf1b3cc9c364a52 Mon Sep 17 00:00:00 2001 From: vsoch Date: Wed, 14 Apr 2021 21:23:10 -0600 Subject: Use `gethostname()` instead of `getfqdn()` for lock debug mode In debug mode, processes taking an exclusive lock write out their node name to the lock file. We were using `getfqdn()` for this, but it seems to produce inconsistent results when used from within some github actions containers. We get this error because getfqdn() seems to return a short name in one place and a fully qualified name in another: ``` File "/home/runner/work/spack/spack/lib/spack/spack/test/llnl/util/lock.py", line 1211, in p1 assert lock.host == self.host AssertionError: assert 'fv-az290-764....cloudapp.net' == 'fv-az290-764' - fv-az290-764.internal.cloudapp.net + fv-az290-764 !!!!!!!!!!!!!!!!!!!! Interrupted: stopping after 1 failures !!!!!!!!!!!!!!!!!!!! == 1 failed, 2547 passed, 7 skipped, 22 xfailed, 2 xpassed in 1238.67 seconds == ``` This seems to stem from https://bugs.python.org/issue5004. We don't really need to get a fully qualified hostname for debugging, so use `gethostname()` because its results are more consistent. This seems to fix the issue. Signed-off-by: vsoch --- lib/spack/llnl/util/lock.py | 2 +- lib/spack/spack/test/llnl/util/lock.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/spack/llnl/util/lock.py b/lib/spack/llnl/util/lock.py index 968e07dbb6..bd3308a57f 100644 --- a/lib/spack/llnl/util/lock.py +++ b/lib/spack/llnl/util/lock.py @@ -264,7 +264,7 @@ class Lock(object): self.old_host = self.host self.pid = os.getpid() - self.host = socket.getfqdn() + self.host = socket.gethostname() # write pid, host to disk to sync over FS self._file.seek(0) diff --git a/lib/spack/spack/test/llnl/util/lock.py b/lib/spack/spack/test/llnl/util/lock.py index ff30cedf6d..4911ac9ae3 100644 --- a/lib/spack/spack/test/llnl/util/lock.py +++ b/lib/spack/spack/test/llnl/util/lock.py @@ -1192,7 +1192,7 @@ def test_nested_reads(lock_path): class LockDebugOutput(object): def __init__(self, lock_path): self.lock_path = lock_path - self.host = socket.getfqdn() + self.host = socket.gethostname() def p1(self, barrier, q1, q2): # exchange pids -- cgit v1.2.3-60-g2f50