summaryrefslogtreecommitdiff
path: root/buildscripts
diff options
context:
space:
mode:
authorDaniel Moody <daniel.moody@mongodb.com>2022-08-12 20:12:46 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-12 20:42:58 +0000
commit3af863123ffe506578c483fff51a0871f485b987 (patch)
treeaa57daea5bd253746fcee2434b05526d32fa747e /buildscripts
parenta0438659bfd3940d12e4a3639294573a555bbead (diff)
downloadmongo-3af863123ffe506578c483fff51a0871f485b987.tar.gz
SERVER-68637 disable cache metrics for static hosts
Diffstat (limited to 'buildscripts')
-rw-r--r--buildscripts/scons_metrics/metrics.py7
-rw-r--r--buildscripts/scons_metrics/report.py19
2 files changed, 20 insertions, 6 deletions
diff --git a/buildscripts/scons_metrics/metrics.py b/buildscripts/scons_metrics/metrics.py
index 1ba1f7825ad..125204dc4ac 100644
--- a/buildscripts/scons_metrics/metrics.py
+++ b/buildscripts/scons_metrics/metrics.py
@@ -105,8 +105,11 @@ class SconsMetrics: # pylint: disable=too-many-instance-attributes
self.total_command_execution_time = self._parse_float(
TOTAL_COMMAND_EXECUTION_TIME_REGEX, self.raw_report)
- with open(cache_debug_log_file, "r") as fh:
- self.final_cache_hit_ratio = self._parse_float(CACHE_HIT_RATIO_REGEX, fh.read())
+ if cache_debug_log_file:
+ with open(cache_debug_log_file, "r") as fh:
+ self.final_cache_hit_ratio = self._parse_float(CACHE_HIT_RATIO_REGEX, fh.read())
+ else:
+ self.final_cache_hit_ratio = 0.0
def make_cedar_report(self) -> List[dict]:
"""Format the data to look like a cedar report json."""
diff --git a/buildscripts/scons_metrics/report.py b/buildscripts/scons_metrics/report.py
index 61b60ccc186..cae5e5ef1d0 100644
--- a/buildscripts/scons_metrics/report.py
+++ b/buildscripts/scons_metrics/report.py
@@ -27,14 +27,25 @@ def main(scons_stdout_log_file: str, scons_cache_debug_log_file: str,
scons_cache_debug_log_file = os.path.abspath(scons_cache_debug_log_file)
cedar_report_file = os.path.abspath(cedar_report_file)
+ # This is a special file which must be available to use scons cache in evergreen. Here
+ # we are assuming that if this file is not present then this a static host which
+ # can not use scons cache in evergreen so therefore we will disable colleting cache metrics.
+ # Otherwise we assume the cache is available and if the cache log file is not found,
+ # something is not right and we exit with failure.
+ if not os.path.exists('/etc/mongodb-build-system-id'):
+ print(
+ "System is a static host and not connected to AWS cache dir. Skipping scons cache metrics."
+ )
+ scons_cache_debug_log_file = None
+ else:
+ if not os.path.exists(scons_cache_debug_log_file):
+ print(f"Could not find SCons cache debug log file '{scons_cache_debug_log_file}'.")
+ sys.exit(1)
+
if not os.path.exists(scons_stdout_log_file):
print(f"Could not find SCons stdout log file '{scons_stdout_log_file}'.")
sys.exit(1)
- if not os.path.exists(scons_cache_debug_log_file):
- print(f"Could not find SCons cache debug log file '{scons_cache_debug_log_file}'.")
- sys.exit(1)
-
scons_metrics = SconsMetrics(scons_stdout_log_file, scons_cache_debug_log_file)
if not scons_metrics.raw_report:
print(