Skip to content

Commit

Permalink
Handle target hangs immediately after launch
Browse files Browse the repository at this point in the history
This is a workaround to prevent grizzly from hanging.
A more complete solution should be created.
  • Loading branch information
tysmith committed Dec 6, 2023
1 parent 68d4d14 commit 140913b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions grizzly/common/bugzilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

# attachments that can be ignored
IGNORE_EXTS = frozenset({"c", "cpp", "diff", "exe", "log", "patch", "php", "py", "txt"})
# TODO: support all target assets
KNOWN_ASSETS = {"prefs": "prefs.js"}
LOG = getLogger(__name__)

Expand Down
17 changes: 12 additions & 5 deletions grizzly/common/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,12 @@ def post_launch(self, delay=-1):
srv_map = ServerMap()
srv_map.set_redirect("grz_start", content.entry_point, required=False)
srv_map.set_redirect("grz_continue", "grz_start", required=True)
# temporarily disable server timeout
srv_timeout = self._server.timeout
self._server.timeout = 0
# temporarily override server timeout
org_timeout = self._server.timeout
# add time buffer to redirect delay
# in practice this should take a few seconds (~10s)
# in extreme cases ~40s (slow build + debugger)
self._server.timeout = delay + 180
if delay > 0:
LOG.info("Browser launched, continuing in %ds...", delay)
# serve prompt page
Expand All @@ -241,12 +244,16 @@ def post_launch(self, delay=-1):
continue_cb=self._target.monitor.is_healthy,
server_map=srv_map,
)
# reset server timeout
self._server.timeout = srv_timeout
# restore server timeout
self._server.timeout = org_timeout
if server_status != Served.ALL:
self.startup_failure = True
if server_status == Served.TIMEOUT:
# this should never happen with a correctly functioning build
LOG.warning("Target hung after launch")

if self.startup_failure:
# TODO: we need a better way to handle delayed startup failures
LOG.warning("Post launch check failed!")

def run(
Expand Down
2 changes: 2 additions & 0 deletions grizzly/common/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ def test_runner_11(mocker):
(-1, None, False),
# startup failure
(0, (Served.NONE, None), True),
# target hang while loading content
(0, (Served.TIMEOUT, None), True),
],
)
def test_runner_12(mocker, delay, srv_result, startup_failure):
Expand Down

0 comments on commit 140913b

Please sign in to comment.