Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better raw output to download in Rocky from Bytes on crashes #936

Merged
merged 6 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions boefjes/boefjes/job_handler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import traceback
from datetime import datetime, timedelta, timezone
from enum import Enum
from typing import Any, Dict, List, Set
Expand Down Expand Up @@ -136,9 +137,9 @@ def handle(self, boefje_meta: BoefjeMeta) -> None:

try:
boefje_results = self.job_runner.run(boefje_meta, environment)
except Exception as e:
except Exception:
logger.exception("Error running boefje %s[%s]", boefje_meta.boefje.id, boefje_meta.id)
boefje_results = [({"error/boefje"}, str(e))]
boefje_results = [({"error/boefje"}, traceback.format_exc())]

raise
finally:
Expand Down
22 changes: 12 additions & 10 deletions boefjes/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,18 @@ def test_handle_boefje_with_exception(self, mock_find_ooi_in_past, mock_bytes_ap
BoefjeHandler(LocalBoefjeJobRunner(local_repository), local_repository).handle(meta)

mock_bytes_api_client.save_boefje_meta.assert_called_once_with(meta)
mock_bytes_api_client.save_raw.assert_called_once_with(
"some-random-job-id",
"Boefje failed",
{
"error/boefje",
"dummy_boefje_runtime_exception",
"boefje/dummy_boefje_runtime_exception",
f"boefje/dummy_boefje_runtime_exception-{meta.parameterized_arguments_hash}",
},
)
mock_bytes_api_client.save_raw.assert_called_once()
raw_call_args = mock_bytes_api_client.save_raw.call_args

assert raw_call_args[0][0] == "some-random-job-id"
assert "Traceback (most recent call last)" in raw_call_args[0][1]
assert "JobRuntimeError: Boefje failed" in raw_call_args[0][1]
assert raw_call_args[0][2] == {
"error/boefje",
"dummy_boefje_runtime_exception",
"boefje/dummy_boefje_runtime_exception",
f"boefje/dummy_boefje_runtime_exception-{meta.parameterized_arguments_hash}",
}

def test_exception_raised_unsupported_return_type_normalizer(self):
meta = NormalizerMeta.parse_raw(get_dummy_data("dns-normalize.json"))
Expand Down