Skip to content
Snippets Groups Projects
Verified Commit ee074f0e authored by Antoine Lambert's avatar Antoine Lambert
Browse files

cli/sentry: Fix issues with the extract-scheduler-tasks command

If some task parameters are of type dict or list, the command was
previously crashing.
parent 32f72ec7
No related branches found
No related tags found
1 merge request!411Improve swh sentry extract-scheduler-tasks command
Pipeline #13700 passed
......@@ -74,7 +74,7 @@ def _process_sentry_events_pages(
)
if full_sentry_responses:
sentry_issue_events_url += "?full=true"
while True:
while sentry_issue_events_url:
response = requests.get(
sentry_issue_events_url, headers={"Authorization": f"Bearer {sentry_token}"}
)
......@@ -145,7 +145,7 @@ def extract_scheduler_tasks(
task_name = celery_job.get("task_name")
task_param = celery_job.get("kwargs")
if task_param:
key = tuple([task_name] + list(task_param.values()))
key = tuple([task_name] + list(str(v) for v in task_param.values()))
task_params[key] = (task_name, task_param)
_process_sentry_events_pages(
......
[
{
"tags": [
{
"key": "environment",
"value": "production"
},
{
"key": "swh.loader.origin_url",
"value": "https://github.com/pjbgf/sha1cd"
}
],
"context": {
"celery-job": {
"args": [],
"kwargs": {
"checksum_layout": "nar",
"checksums": {
"sha256": "917f4174b876771b4635a0ef736e0d3913be0b4019ec9cdbad7aed79c09d07bc"
},
"fallback_urls": [],
"lister_instance_name": "guix.gnu.org",
"lister_name": "nixguix",
"ref": "v0.3.0",
"url": "https://github.com/pjbgf/sha1cd"
},
"task_name": "swh.loader.git.tasks.LoadGitCheckout"
}
}
}
]
\ No newline at end of file
......@@ -92,3 +92,21 @@ def test_sentry_extract_scheduler_tasks_recurring_policy(
csv_tasks_file = os.path.join(datadir, "sentry_expected_scheduler_tasks.csv")
with open(csv_tasks_file, "r") as tasks_csv:
assert result.output.strip() == tasks_csv.read().replace("oneshot", "recurring")
def test_sentry_extract_scheduler_tasks_dict_and_list_task_params(
swhmain, requests_mock_datadir
):
runner = CliRunner()
result = runner.invoke(
swhmain,
[
"sentry",
"extract-scheduler-tasks",
"-t",
"sentry-token",
"-i",
"1",
],
)
assert_result(result)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment