Skip to content

Commit

Permalink
Cdash reporting timeout (spack#44213)
Browse files Browse the repository at this point in the history
* Add timeout to cdash reporter PUT request

Add cdash timeout everywhere
Correct mock responder api

* Style

* brief doc
  • Loading branch information
johnwparent authored May 15, 2024
1 parent d058928 commit 43291aa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions lib/spack/spack/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from spack import traverse
from spack.error import SpackError
from spack.reporters import CDash, CDashConfiguration
from spack.reporters.cdash import SPACK_CDASH_TIMEOUT
from spack.reporters.cdash import build_stamp as cdash_build_stamp

# See https://docs.gitlab.com/ee/ci/yaml/#retry for descriptions of conditions
Expand Down Expand Up @@ -1506,7 +1507,7 @@ def download_and_extract_artifacts(url, work_dir):
request = Request(url, headers=headers)
request.get_method = lambda: "GET"

response = opener.open(request)
response = opener.open(request, timeout=SPACK_CDASH_TIMEOUT)
response_code = response.getcode()

if response_code != 200:
Expand Down Expand Up @@ -2254,7 +2255,7 @@ def create_buildgroup(self, opener, headers, url, group_name, group_type):

request = Request(url, data=enc_data, headers=headers)

response = opener.open(request)
response = opener.open(request, timeout=SPACK_CDASH_TIMEOUT)
response_code = response.getcode()

if response_code not in [200, 201]:
Expand Down Expand Up @@ -2300,7 +2301,7 @@ def populate_buildgroup(self, job_names):
request = Request(url, data=enc_data, headers=headers)
request.get_method = lambda: "PUT"

response = opener.open(request)
response = opener.open(request, timeout=SPACK_CDASH_TIMEOUT)
response_code = response.getcode()

if response_code != 200:
Expand Down
5 changes: 3 additions & 2 deletions lib/spack/spack/reporters/cdash.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
# Initialize data structures common to each phase's report.
CDASH_PHASES = set(MAP_PHASES_TO_CDASH.values())
CDASH_PHASES.add("update")

# CDash request timeout in seconds
SPACK_CDASH_TIMEOUT = 45

CDashConfiguration = collections.namedtuple(
"CDashConfiguration", ["upload_url", "packages", "build", "site", "buildstamp", "track"]
Expand Down Expand Up @@ -447,7 +448,7 @@ def upload(self, filename):
# By default, urllib2 only support GET and POST.
# CDash expects this file to be uploaded via PUT.
request.get_method = lambda: "PUT"
response = opener.open(request)
response = opener.open(request, timeout=SPACK_CDASH_TIMEOUT)
if self.current_package_name not in self.buildIds:
resp_value = response.read()
if isinstance(resp_value, bytes):
Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/test/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, response_code=200, content_to_read=[]):
self._content = content_to_read
self._read = [False for c in content_to_read]

def open(self, request):
def open(self, request, data=None, timeout=object()):
return self

def getcode(self):
Expand Down

0 comments on commit 43291aa

Please sign in to comment.