summaryrefslogtreecommitdiff
path: root/buildscripts
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2021-07-30 11:39:11 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-09-20 14:35:27 +0000
commit5592451738333826168b4582fd270cc32effc1de (patch)
tree72206b06704971a59de006335fbeb5a98774a519 /buildscripts
parent3db2eccd331b3c382fea07f6c9c01edcbe8e8736 (diff)
downloadmongo-5592451738333826168b4582fd270cc32effc1de.tar.gz
SERVER-57780 Improve BlackDuck timeout handling
(cherry picked from commit 69b4c29d7486b66bc4a09c8eeeee6a0d575db510)
Diffstat (limited to 'buildscripts')
-rw-r--r--buildscripts/blackduck_hub.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/buildscripts/blackduck_hub.py b/buildscripts/blackduck_hub.py
index bdab210a43a..53b6af52dd7 100644
--- a/buildscripts/blackduck_hub.py
+++ b/buildscripts/blackduck_hub.py
@@ -422,6 +422,23 @@ def _test_version_info():
assert VersionInfo('7.0.2.2') <= VersionInfo('8.0.2')
+def _retry_on_except(count, func):
+ # Retry func() COUNT times until func() does not raise an exception
+ # pylint: disable=bare-except
+ retry = 0
+ while retry < count:
+
+ try:
+ return func()
+ except:
+ exception_info = sys.exc_info()[0]
+ LOGGER.error("Failed to execute retriable function (%s), retrying", exception_info)
+
+ retry += 1
+
+ raise ValueError("Failed to run query after retries %s" % (count))
+
+
class Component:
"""
Black Duck Component description.
@@ -469,7 +486,17 @@ class Component:
versions_url = component["component"] + f"/versions?sort=releasedon%20desc&limit={limit}"
LOGGER.info("Retrieving version information via %s", versions_url)
- vjson = hub.execute_get(versions_url).json()
+
+ def get_version_info():
+ vjson = hub.execute_get(versions_url).json()
+
+ if "items" not in vjson:
+ LOGGER.warn("Missing items in response: %s", vjson)
+ raise ValueError("Missing items in response for " + versions_url)
+
+ return vjson
+
+ vjson = _retry_on_except(5, get_version_info)
versions = [(ver["versionName"], ver["releasedOn"]) for ver in vjson["items"]]
@@ -559,6 +586,15 @@ def _query_blackduck():
hub = HubInstance()
+ LOGGER.info("Getting version from blackduck")
+ version = hub.execute_get(hub.get_urlbase() + "/api/current-version").json()
+ LOGGER.info("Version: %s", version)
+
+ # Get a list of all projects, this is a privileged call and will fail if we do not have a valid license
+ LOGGER.info("Get All Projects")
+ projects = hub.get_projects()
+ LOGGER.info("Projects: %s", projects)
+
LOGGER.info("Fetching project %s from blackduck", BLACKDUCK_PROJECT)
project = hub.get_project_by_name(BLACKDUCK_PROJECT)