Bug 1416314 - Guard against psutil exceptions when generating system-info.log. r=jmaher, a=test-only
authorGeoff Brown <gbrown@mozilla.com>
Mon, 13 Nov 2017 13:11:59 -0700
changeset 444766 d37f4f80965b7ea351dbf4c859a6d784bded62b5
parent 444765 e8f0d29cabecc5f6c83573329bbe736cbd6481e6
child 444767 139db886b646719c635ae3854262ca90c3fc0112
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher, test-only
bugs1416314
milestone58.0
Bug 1416314 - Guard against psutil exceptions when generating system-info.log. r=jmaher, a=test-only It seems psutil can throw a wide range of exceptions when accessing system information on aws...intermittently, of course. Let's expect and discard such exceptions so that test jobs are not dependent on creating system-info.log.
testing/mozharness/scripts/desktop_unittest.py
--- a/testing/mozharness/scripts/desktop_unittest.py
+++ b/testing/mozharness/scripts/desktop_unittest.py
@@ -671,42 +671,44 @@ class DesktopUnittest(TestingMixin, Merc
 
     def _report_system_info(self):
         """
            Create the system-info.log artifact file, containing a variety of
            system information that might be useful in diagnosing test failures.
         """
         try:
             import psutil
+            dir = self.query_abs_dirs()['abs_blob_upload_dir']
+            self.mkdir_p(dir)
+            path = os.path.join(dir, "system-info.log")
+            with open(path, "w") as f:
+                self._report_line(f, "System info collected at ", datetime.now())
+                self._report_line(f, "\nBoot time ",
+                                  datetime.fromtimestamp(psutil.boot_time()))
+                self._report_line(f, "\nVirtual memory: ", psutil.virtual_memory())
+                self._report_line(f, "\nDisk partitions: ", psutil.disk_partitions())
+                self._report_line(f, "\nDisk usage (/): ", psutil.disk_usage(os.path.sep))
+                self._report_line(f, "\nUsers: ", psutil.users())
+                self._report_line(f, "\nNetwork connections:", "")
+                try:
+                    for nc in psutil.net_connections():
+                        self._report_line(f, "  ", nc)
+                except:
+                    f.write("Exception getting network info: %s" % sys.exc_info()[0])
+                self._report_line(f, "\nProcesses:", "")
+                try:
+                    for p in psutil.process_iter():
+                        ctime = str(datetime.fromtimestamp(p.create_time()))
+                        self._report_line(f, "  PID", "%d %s %s created at %s" %
+                                          (p.pid, p.name(), str(p.cmdline()), ctime))
+                except:
+                    f.write("Exception getting process info: %s" % sys.exc_info()[0])
         except:
-            return
-        dir = self.query_abs_dirs()['abs_blob_upload_dir']
-        self.mkdir_p(dir)
-        path = os.path.join(dir, "system-info.log")
-        with open(path, "w") as f:
-            self._report_line(f, "System info collected at ", datetime.now())
-            self._report_line(f, "\nBoot time ", datetime.fromtimestamp(psutil.boot_time()))
-            self._report_line(f, "\nVirtual memory: ", psutil.virtual_memory())
-            self._report_line(f, "\nDisk partitions: ", psutil.disk_partitions())
-            self._report_line(f, "\nDisk usage (/): ", psutil.disk_usage(os.path.sep))
-            self._report_line(f, "\nUsers: ", psutil.users())
-            self._report_line(f, "\nNetwork connections:", "")
-            try:
-                for nc in psutil.net_connections():
-                    self._report_line(f, "  ", nc)
-            except:
-                f.write("Exception getting network info: %s" % sys.exc_info()[0])
-            self._report_line(f, "\nProcesses:", "")
-            try:
-                for p in psutil.process_iter():
-                    ctime = str(datetime.fromtimestamp(p.create_time()))
-                    self._report_line(f, "  PID", "%d %s %s created at %s" %
-                                      (p.pid, p.name(), str(p.cmdline()), ctime))
-            except:
-                f.write("Exception getting process info: %s" % sys.exc_info()[0])
+            # psutil throws a variety of intermittent exceptions
+            self.info("Unable to complete system-info.log: %s" % sys.exc_info()[0])
 
     # pull defined in VCSScript.
     # preflight_run_tests defined in TestingMixin.
 
     def run_tests(self):
         self._report_system_info()
         self.start_time = datetime.now()
         for category in SUITE_CATEGORIES: