summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorvsoch <vsoch@users.noreply.github.com>2021-04-14 21:23:10 -0600
committerTodd Gamblin <tgamblin@llnl.gov>2021-04-15 00:01:41 -0700
commit613348ec90e41e3e403fe4566bf1b3cc9c364a52 (patch)
tree30ffe820eb4cafb8ffb3cf4495013cb4930d2235 /lib
parent393542064d07a00c57d0a0da0f3d054f53ec3220 (diff)
downloadspack-613348ec90e41e3e403fe4566bf1b3cc9c364a52.tar.gz
spack-613348ec90e41e3e403fe4566bf1b3cc9c364a52.tar.bz2
spack-613348ec90e41e3e403fe4566bf1b3cc9c364a52.tar.xz
spack-613348ec90e41e3e403fe4566bf1b3cc9c364a52.zip
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 <vsoch@users.noreply.github.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/llnl/util/lock.py2
-rw-r--r--lib/spack/spack/test/llnl/util/lock.py2
2 files changed, 2 insertions, 2 deletions
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