0
0
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:
Richard Samuels 2021-05-20 09:48:06 -04:00 committed by Evergreen Agent
parent fcb032a181
commit b2802257c7
4 changed files with 19 additions and 18 deletions

View File

@ -17,8 +17,10 @@ import re
import signal import signal
import sys import sys
import traceback import traceback
import getpass
import psutil import psutil
import distro
from buildscripts.resmokelib.hang_analyzer import extractor from buildscripts.resmokelib.hang_analyzer import extractor
from buildscripts.resmokelib.hang_analyzer import dumper from buildscripts.resmokelib.hang_analyzer import dumper
@ -168,22 +170,18 @@ class HangAnalyzer(Subcommand):
try: try:
if sys.platform == "win32" or sys.platform == "cygwin": if sys.platform == "win32" or sys.platform == "cygwin":
distro = platform.win32_ver() self.root_logger.info("Windows Distribution: %s", platform.win32_ver())
self.root_logger.info("Windows Distribution: %s", distro)
else: else:
distro = platform.linux_distribution() self.root_logger.info("Linux Distribution: %s", distro.linux_distribution())
self.root_logger.info("Linux Distribution: %s", distro)
except AttributeError: except AttributeError:
self.root_logger.warning("Cannot determine Linux distro since Python is too old") self.root_logger.warning("Cannot determine Linux distro since Python is too old")
try: try:
uid = os.getuid() current_login = getpass.getuser()
self.root_logger.info("Current User: %s", uid)
current_login = os.getlogin()
self.root_logger.info("Current Login: %s", current_login) self.root_logger.info("Current Login: %s", current_login)
except OSError: uid = os.getuid()
self.root_logger.warning("Cannot determine Unix Current Login") self.root_logger.info("Current UID: %s", uid)
except AttributeError: except AttributeError:
self.root_logger.warning( self.root_logger.warning(
"Cannot determine Unix Current Login, not supported on Windows") "Cannot determine Unix Current Login, not supported on Windows")

View File

@ -50,14 +50,19 @@ def get_processes(process_ids, interesting_processes, process_match, logger):
processes_to_keep = [] processes_to_keep = []
for process in all_processes: for process in all_processes:
# skip self
if process.pidv == os.getpid(): if process.pidv == os.getpid():
continue 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: if process_ids and process.pidv not in process_ids:
continue continue
if interesting_processes and not _pname_match(process_match, process.name, # if we don't have a list of pids, make sure the process matches
interesting_processes): # the list of interesting processes
if not process_ids and interesting_processes and not _pname_match(
process_match, process.name, interesting_processes):
continue continue
processes_to_keep.append(process) processes_to_keep.append(process)

View File

@ -48,13 +48,9 @@ class TestGetProcesses(unittest.TestCase):
@patch(ns("_get_lister")) @patch(ns("_get_lister"))
def test_interesting_processes_and_process_ids(self, lister_mock, os_mock): def test_interesting_processes_and_process_ids(self, lister_mock, os_mock):
os_mock.return_value = -1 os_mock.return_value = -1
lister_mock.return_value.dump_processes.return_value = [ lister_mock.return_value.dump_processes.return_value = [(1, "python"), (2, "mongo"),
(1, "python"), (3, "python"), (4, "mongod"),
(2, "mongo"), (5, "java")]
(3, "python"),
(4, "mongod"),
(5, "java") # this should be ignored.
]
process_ids = [1, 2, 5] process_ids = [1, 2, 5]
interesting_processes = ['python', 'mongo', 'mongod'] interesting_processes = ['python', 'mongo', 'mongod']
@ -66,6 +62,7 @@ class TestGetProcesses(unittest.TestCase):
self.assertCountEqual(processes, [ self.assertCountEqual(processes, [
Pinfo(name="python", pidv=[1]), Pinfo(name="python", pidv=[1]),
Pinfo(name="mongo", pidv=[2]), Pinfo(name="mongo", pidv=[2]),
Pinfo(name="java", pidv=[5]),
]) ])
@patch(ns("os.getpid")) @patch(ns("os.getpid"))

View File

@ -14,3 +14,4 @@ googleapis-common-protos == 1.53.0
blackduck == 1.0.1 blackduck == 1.0.1
PyGithub == 1.53 PyGithub == 1.53
urllib3 >= 1.26.0 urllib3 >= 1.26.0
distro == 1.5.0