summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildscripts/resmokelib/utils/evergreen_conn.py56
-rw-r--r--evergreen/hang_analyzer.sh6
2 files changed, 40 insertions, 22 deletions
diff --git a/buildscripts/resmokelib/utils/evergreen_conn.py b/buildscripts/resmokelib/utils/evergreen_conn.py
index 4b6e9a44bed..c73590a4b7d 100644
--- a/buildscripts/resmokelib/utils/evergreen_conn.py
+++ b/buildscripts/resmokelib/utils/evergreen_conn.py
@@ -1,6 +1,7 @@
"""Helper functions to interact with evergreen."""
import os
-from typing import Optional
+import pathlib
+from typing import Optional, List
import requests
import structlog
@@ -17,8 +18,6 @@ EVERGREEN_CONFIG_LOCATIONS = (
# Common for local machines
os.path.expanduser(os.path.join("~", ".evergreen.yml")),
)
-if "EVERGREEN_WORKDIR" in os.environ:
- EVERGREEN_CONFIG_LOCATIONS = (os.environ["EVERGREEN_WORKDIR"], ) + EVERGREEN_CONFIG_LOCATIONS
GENERIC_EDITION = "base"
GENERIC_PLATFORM = "linux_x86_64"
@@ -33,23 +32,46 @@ class EvergreenConnError(Exception):
pass
+def _find_evergreen_yaml_candidates() -> List[str]:
+ # Common for machines in Evergreen
+ candidates = [os.getcwd()]
+
+ cwd = pathlib.Path(os.getcwd())
+ # add every path that is the parent of CWD as well
+ for parent in cwd.parents:
+ candidates.append(parent)
+
+ # Common for local machines
+ candidates.append(os.path.expanduser(os.path.join("~", ".evergreen.yml")))
+
+ out = []
+ for path in candidates:
+ file = os.path.join(path, ".evergreen.yml")
+ if os.path.isfile(file):
+ out.append(file)
+
+ return out
+
+
def get_evergreen_api(evergreen_config=None):
"""Return evergreen API."""
- config_to_pass = evergreen_config
- if not config_to_pass:
- # Pickup the first config file found in common locations.
- for file in EVERGREEN_CONFIG_LOCATIONS:
- if os.path.isfile(file):
- config_to_pass = file
- break
- try:
- evg_api = RetryingEvergreenApi.get_api(config_file=config_to_pass)
- except Exception as ex:
- LOGGER.error("Most likely something is wrong with evergreen config file.",
- config_file=config_to_pass)
- raise ex
+ if evergreen_config:
+ possible_configs = [evergreen_config]
else:
- return evg_api
+ possible_configs = _find_evergreen_yaml_candidates()
+
+ last_ex = None
+ for config in possible_configs:
+ try:
+ return RetryingEvergreenApi.get_api(config_file=config)
+ #
+ except Exception as ex: # pylint: disable=broad-except
+ last_ex = ex
+ continue
+
+ LOGGER.error("Most likely something is wrong with evergreen config file.",
+ config_file_candidates=possible_configs)
+ raise last_ex
def get_buildvariant_name(config, edition, platform, architecture, major_minor_version):
diff --git a/evergreen/hang_analyzer.sh b/evergreen/hang_analyzer.sh
index d02119b9904..104f9b5b30a 100644
--- a/evergreen/hang_analyzer.sh
+++ b/evergreen/hang_analyzer.sh
@@ -15,11 +15,7 @@ fi
activate_venv
echo "Calling the hang analyzer: PATH=\"/opt/mongodbtoolchain/gdb/bin:$PATH\" $python buildscripts/resmoke.py hang-analyzer $hang_analyzer_option"
-evergreen_workdir="${workdir}"
-if [ "Windows_NT" = "$OS" ]; then
- evergreen_workdir="$(cygpath -w ${workdir})"
-fi
-EVERGREEN_WORKDIR="${evergreen_workdir}" PATH="/opt/mongodbtoolchain/gdb/bin:$PATH" $python buildscripts/resmoke.py hang-analyzer $hang_analyzer_option
+PATH="/opt/mongodbtoolchain/gdb/bin:$PATH" $python buildscripts/resmoke.py hang-analyzer $hang_analyzer_option
# Call hang analyzer for tasks that are running remote mongo processes
if [ -n "${private_ip_address}" ]; then