mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-56528 hang analyzer should always run when supplied a pid
This commit is contained in:
parent
fcb032a181
commit
b2802257c7
@ -17,8 +17,10 @@ import re
|
||||
import signal
|
||||
import sys
|
||||
import traceback
|
||||
import getpass
|
||||
|
||||
import psutil
|
||||
import distro
|
||||
|
||||
from buildscripts.resmokelib.hang_analyzer import extractor
|
||||
from buildscripts.resmokelib.hang_analyzer import dumper
|
||||
@ -168,22 +170,18 @@ class HangAnalyzer(Subcommand):
|
||||
|
||||
try:
|
||||
if sys.platform == "win32" or sys.platform == "cygwin":
|
||||
distro = platform.win32_ver()
|
||||
self.root_logger.info("Windows Distribution: %s", distro)
|
||||
self.root_logger.info("Windows Distribution: %s", platform.win32_ver())
|
||||
else:
|
||||
distro = platform.linux_distribution()
|
||||
self.root_logger.info("Linux Distribution: %s", distro)
|
||||
self.root_logger.info("Linux Distribution: %s", distro.linux_distribution())
|
||||
|
||||
except AttributeError:
|
||||
self.root_logger.warning("Cannot determine Linux distro since Python is too old")
|
||||
|
||||
try:
|
||||
uid = os.getuid()
|
||||
self.root_logger.info("Current User: %s", uid)
|
||||
current_login = os.getlogin()
|
||||
current_login = getpass.getuser()
|
||||
self.root_logger.info("Current Login: %s", current_login)
|
||||
except OSError:
|
||||
self.root_logger.warning("Cannot determine Unix Current Login")
|
||||
uid = os.getuid()
|
||||
self.root_logger.info("Current UID: %s", uid)
|
||||
except AttributeError:
|
||||
self.root_logger.warning(
|
||||
"Cannot determine Unix Current Login, not supported on Windows")
|
||||
|
@ -50,14 +50,19 @@ def get_processes(process_ids, interesting_processes, process_match, logger):
|
||||
|
||||
processes_to_keep = []
|
||||
for process in all_processes:
|
||||
# skip self
|
||||
if process.pidv == os.getpid():
|
||||
continue
|
||||
|
||||
# if we've been given a list of pids, and the pid isn't in that list
|
||||
# skip it
|
||||
if process_ids and process.pidv not in process_ids:
|
||||
continue
|
||||
|
||||
if interesting_processes and not _pname_match(process_match, process.name,
|
||||
interesting_processes):
|
||||
# if we don't have a list of pids, make sure the process matches
|
||||
# the list of interesting processes
|
||||
if not process_ids and interesting_processes and not _pname_match(
|
||||
process_match, process.name, interesting_processes):
|
||||
continue
|
||||
|
||||
processes_to_keep.append(process)
|
||||
|
@ -48,13 +48,9 @@ class TestGetProcesses(unittest.TestCase):
|
||||
@patch(ns("_get_lister"))
|
||||
def test_interesting_processes_and_process_ids(self, lister_mock, os_mock):
|
||||
os_mock.return_value = -1
|
||||
lister_mock.return_value.dump_processes.return_value = [
|
||||
(1, "python"),
|
||||
(2, "mongo"),
|
||||
(3, "python"),
|
||||
(4, "mongod"),
|
||||
(5, "java") # this should be ignored.
|
||||
]
|
||||
lister_mock.return_value.dump_processes.return_value = [(1, "python"), (2, "mongo"),
|
||||
(3, "python"), (4, "mongod"),
|
||||
(5, "java")]
|
||||
|
||||
process_ids = [1, 2, 5]
|
||||
interesting_processes = ['python', 'mongo', 'mongod']
|
||||
@ -66,6 +62,7 @@ class TestGetProcesses(unittest.TestCase):
|
||||
self.assertCountEqual(processes, [
|
||||
Pinfo(name="python", pidv=[1]),
|
||||
Pinfo(name="mongo", pidv=[2]),
|
||||
Pinfo(name="java", pidv=[5]),
|
||||
])
|
||||
|
||||
@patch(ns("os.getpid"))
|
||||
|
@ -14,3 +14,4 @@ googleapis-common-protos == 1.53.0
|
||||
blackduck == 1.0.1
|
||||
PyGithub == 1.53
|
||||
urllib3 >= 1.26.0
|
||||
distro == 1.5.0
|
||||
|
Loading…
Reference in New Issue
Block a user