Reland "api: artifacts: Move BundleTestUpdatePayloads into chroot"

This is a reland of commit cb454e0444735d23845f5d092b49c6a6090534bc
now that:
* we've fixed paygen-related libraries to fill out its output fields
  correctly (crrev.com/c/4726924)
* release builders finally rolled to include this recipes change:
  8e8befa09  [briannorris]       cros_artifacts: Fill out BundleRequest.result_path

Original change's description:
> api: artifacts: Move BundleTestUpdatePayloads into chroot
>
> api/gen changes to pull in:
>
>   artifacts: Move BundleTestUpdatePayloads into chroot
>
> We want to run this endpoint inside the chroot, because it forks out to
> many programs that need to enter the chroot, and that's a bit unwieldy
> to do properly (i.e., plumb all the right chroot arguments) in some
> cases.
>
> The router and field_handler layers do most of the artifact (ResultPath
> and Path) translation and copying for us, so we only have to do a few
> things to place artifacts into the in-chroot tmp directory, instead of
> directly into the |result_path|.
>
> I don't convert all the other "legacy" bundle endpoints here, since
> AFAICT, they handle chroot entry properly today.
>
> BUG=b:187787264
> TEST=./run_tests
> TEST=manual build_api execution
>
> Cq-Depend: chromium:4703006
> Change-Id: I60d106bbce1e324850aec4d4fc69fdc054b5c3e2
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/4701636
> Reviewed-by: Alex Klein <saklein@chromium.org>
> Tested-by: Brian Norris <briannorris@chromium.org>
> Commit-Queue: Brian Norris <briannorris@chromium.org>

BUG=b:187787264

Cq-Depend: chromium:4726924
Change-Id: Ib397e339c723cf5fd676c796b278a0b93ab5244d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/4734251
Auto-Submit: Brian Norris <briannorris@chromium.org>
Reviewed-by: Alex Klein <saklein@chromium.org>
Tested-by: Brian Norris <briannorris@chromium.org>
Commit-Queue: Alex Klein <saklein@chromium.org>
diff --git a/api/controller/artifacts.py b/api/controller/artifacts.py
index 95d348c..cb905c4 100644
--- a/api/controller/artifacts.py
+++ b/api/controller/artifacts.py
@@ -309,8 +309,7 @@
 
 @faux.success(_BundleTestUpdatePayloadsResponse)
 @faux.empty_error
-@validate.require("build_target.name", "result_path.path.path")
-@validate.exists("result_path.path.path")
+@validate.require("build_target.name")
 @validate.validation_complete
 def BundleTestUpdatePayloads(
     input_proto: artifacts_pb2.BundleRequest,
@@ -319,9 +318,12 @@
 ) -> Optional[int]:
     """Generate minimal update payloads for the build target for testing."""
     target = input_proto.build_target.name
-    output_dir = input_proto.result_path.path.path
     chroot = controller_util.ParseChroot(input_proto.chroot)
     build_root = constants.SOURCE_ROOT
+    # Leave artifact output intact, for the router layer to copy it out of the
+    # chroot. This may leave stray files leftover, but builders should clean
+    # these up.
+    output_dir = chroot.tempdir(delete=False)
 
     # Use the first available image to create the update payload.
     img_dir = _GetImageDir(build_root, target)
@@ -347,11 +349,13 @@
         )
     image = valid_images[0]
 
-    payloads = artifacts.BundleTestUpdatePayloads(chroot, image, output_dir)
+    payloads = artifacts.BundleTestUpdatePayloads(
+        chroot, image, str(output_dir)
+    )
     for payload in payloads:
         output_proto.artifacts.add(
             artifact_path=common_pb2.Path(
-                path=payload, location=common_pb2.Path.OUTSIDE
+                path=payload, location=common_pb2.Path.INSIDE
             ),
         )