autotest: tko/db.py: require parent_task_id when getting by parent
This function, when given a None id, performs a full tko table scan,
which is both very expensive, unexpected, and a silent failure. Make it
fail loudly instead.
BUG=chromium:966518
TEST=None
Change-Id: I64b20c71c3e87a6505e364b0bdad1564af95c470
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/1628151
Reviewed-by: C Shapiro <shapiroc@chromium.org>
Commit-Queue: Aviv Keshet <akeshet@chromium.org>
Tested-by: Aviv Keshet <akeshet@chromium.org>
diff --git a/tko/db.py b/tko/db.py
index ae10397..96540fe 100644
--- a/tko/db.py
+++ b/tko/db.py
@@ -845,6 +845,8 @@
@param parent_task_id: A string parent task id in tko_task_references.
@return: A list of view dicts, which has key 'test_name' and 'status'.
"""
+ if not parent_task_id:
+ raise ValueError('no parent_task_id supplied')
rows = self.select('tko_job_idx', 'tko_task_references',
{'parent_task_id': parent_task_id})
tko_job_ids = [str(r[0]) for r in rows]