[autotest] Add --offload_failures_only flag for Suites

Adds a new run_suite flag: --offload_failures_only and the required
piping to set it as a job keyval for each subjob of a suite.

Updates the tko_parser to determine if a test was successful or not
and should it be offloaded or not.

Introduces the concept of gs_offloader_instructions json file for
each test. This allows us to improve the intelligence of
gs_offloader by allowing tests to supply information to gs_offloader.

BUG=chromium:471330
TEST=local moblab setup. Ensured that only failed jobs were offloaded.
DEPLOY=gs_offloader,apache

Change-Id: I2310d710f1dce39a70766f6408f6a3c94f493e0d
Reviewed-on: https://chromium-review.googlesource.com/266090
Reviewed-by: Simran Basi <sbasi@chromium.org>
Tested-by: Simran Basi <sbasi@chromium.org>
Commit-Queue: Simran Basi <sbasi@chromium.org>
diff --git a/frontend/afe/site_rpc_interface.py b/frontend/afe/site_rpc_interface.py
index 2976e95..3fce97f 100644
--- a/frontend/afe/site_rpc_interface.py
+++ b/frontend/afe/site_rpc_interface.py
@@ -120,7 +120,7 @@
                      timeout_mins=None, priority=priorities.Priority.DEFAULT,
                      suite_args=None, wait_for_results=True, job_retry=False,
                      max_retries=None, max_runtime_mins=None, suite_min_duts=0,
-                     **kwargs):
+                     offload_failures_only=False, **kwargs):
     """
     Create a job to run a test suite on the given device with the given image.
 
@@ -155,6 +155,7 @@
                            minimum number of machines for the suite when it is
                            competing with another suite that has a higher
                            priority but already got minimum machines it needs.
+    @param offload_failures_only: Only enable gs_offloading for failed jobs.
     @param kwargs: extra keyword args. NOT USED.
 
     @raises ControlFileNotFound: if a unique suite control file doesn't exist.
@@ -203,6 +204,7 @@
                    'job_retry': job_retry,
                    'max_retries': max_retries,
                    'max_runtime_mins': max_runtime_mins,
+                   'offload_failures_only': offload_failures_only
                    }
 
     control_file = tools.inject_vars(inject_dict, control_file)