From: David Galloway Date: Fri, 15 May 2026 22:08:17 +0000 (-0400) Subject: task/install/deb: Add'l debugging info for held apt lock X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F2201%2Fhead;p=teuthology.git task/install/deb: Add'l debugging info for held apt lock For https://tracker.ceph.com/issues/73843 Signed-off-by: David Galloway --- diff --git a/teuthology/task/install/deb.py b/teuthology/task/install/deb.py index e1a290f78..fd154212d 100644 --- a/teuthology/task/install/deb.py +++ b/teuthology/task/install/deb.py @@ -20,10 +20,26 @@ def _retry_if_eagain_in_output(remote, args): return remote.run(args=args, stderr=stderr) except run.CommandFailedError: if "could not get lock" in stderr.getvalue().lower(): - stdout = StringIO() - args = ['sudo', 'fuser', '-v', '/var/lib/dpkg/lock-frontend'] - remote.run(args=args, stdout=stdout) - log.info("The processes holding 'lock-frontend':\n{}".format(stdout.getvalue())) + # Get the PID(s) holding the lock. Set to empty list in case + # apt lock is freed between original apt failure and `fuser` call + try: + pids = remote.sh('sudo fuser /var/lib/dpkg/lock-frontend').split() + except run.CommandFailedError: + pids = [] + log.info("The processes holding 'lock-frontend':\n{}".format(pids)) + + # Get detailed info on each PID + for pid in pids: + try: + ps_out = remote.sh(f'ps -p {pid} -o pid,ppid,user,stat,start,etime,cmd') + log.info("Process info for PID %s:\n%s", pid, ps_out) + + cmdline = remote.sh(f'sudo cat /proc/{pid}/cmdline') + cmdline = cmdline.replace('\x00', ' ').strip() + log.info("Full cmdline for PID %s: %s", pid, cmdline) + except run.CommandFailedError: + log.info("PID %s exited before we could inspect it", pid) + continue else: raise