aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/server/process.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-12-08 17:29:49 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-12-08 17:35:10 +0000
commit22685460b5ecb1aeb4ff3436088ecdacb43044d7 (patch)
treeb4b019bb14605df549b4ac673634f8f232a37836 /lib/bb/server/process.py
parenta1a86f8c311cb1fc4f5562f1c77f82aa95141eee (diff)
downloadbitbake-22685460b5ecb1aeb4ff3436088ecdacb43044d7.tar.gz
main/server: Add lockfile debugging upon server retry
We keep seeing server issues where the lockfile is present but we can't connect to it. Reuse the lockfile debugging code from the server to dump better information to the console from the client side when we run into this issue. Whilst not pretty, this might give us a chance of being able to debug the problems further. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/server/process.py')
-rw-r--r--lib/bb/server/process.py53
1 files changed, 31 insertions, 22 deletions
diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py
index afd77ac0a..f4ab80ba6 100644
--- a/lib/bb/server/process.py
+++ b/lib/bb/server/process.py
@@ -41,6 +41,35 @@ def serverlog(msg):
print(str(os.getpid()) + " " + datetime.datetime.now().strftime('%H:%M:%S.%f') + " " + msg)
sys.stdout.flush()
+#
+# When we have lockfile issues, try and find infomation about which process is
+# using the lockfile
+#
+def get_lockfile_process_msg(lockfile):
+ # Some systems may not have lsof available
+ procs = None
+ try:
+ procs = subprocess.check_output(["lsof", '-w', lockfile], stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError:
+ # File was deleted?
+ pass
+ except OSError as e:
+ if e.errno != errno.ENOENT:
+ raise
+ if procs is None:
+ # Fall back to fuser if lsof is unavailable
+ try:
+ procs = subprocess.check_output(["fuser", '-v', lockfile], stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError:
+ # File was deleted?
+ pass
+ except OSError as e:
+ if e.errno != errno.ENOENT:
+ raise
+ if procs:
+ return procs.decode("utf-8")
+ return None
+
class ProcessServer():
profile_filename = "profile.log"
profile_processed_filename = "profile.log.processed"
@@ -306,30 +335,10 @@ class ProcessServer():
return
if not lock:
- # Some systems may not have lsof available
- procs = None
- try:
- procs = subprocess.check_output(["lsof", '-w', lockfile], stderr=subprocess.STDOUT)
- except subprocess.CalledProcessError:
- # File was deleted?
- continue
- except OSError as e:
- if e.errno != errno.ENOENT:
- raise
- if procs is None:
- # Fall back to fuser if lsof is unavailable
- try:
- procs = subprocess.check_output(["fuser", '-v', lockfile], stderr=subprocess.STDOUT)
- except subprocess.CalledProcessError:
- # File was deleted?
- continue
- except OSError as e:
- if e.errno != errno.ENOENT:
- raise
-
+ procs = get_lockfile_process_msg(lockfile)
msg = ["Delaying shutdown due to active processes which appear to be holding bitbake.lock"]
if procs:
- msg.append(":\n%s" % str(procs.decode("utf-8")))
+ msg.append(":\n%s" % procs)
serverlog("".join(msg))
def idle_commands(self, delay, fds=None):