Goma: Fix log dir handling.

Make goma parsing optional to allow the handlers to affect the
chroot-based dynamic configs. Fix the log dir handling to
pass through a valid path to the Goma instance.

BUG=chromium:1031259
TEST=run_tests

Change-Id: I3e4fa23b8ba72b2209053422da98bbf2ea70e5d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1972711
Tested-by: Alex Klein <saklein@chromium.org>
Reviewed-by: David Burger <dburger@chromium.org>
Commit-Queue: Alex Klein <saklein@chromium.org>
diff --git a/api/router.py b/api/router.py
index df4094f..95eab8e 100644
--- a/api/router.py
+++ b/api/router.py
@@ -243,12 +243,18 @@
       method_name (str): The name of the method to run.
       config (api_config.ApiConfig): The optional call configs.
     """
-    # Parse the chroot and clear the chroot field in the input message.
-    chroot = field_handler.handle_chroot(input_msg)
+    # TODO(saklein): Fix the chroot/goma handling.
+
+    # First parse is just the chroot itself so we can use the tempdir.
+    chroot = field_handler.handle_chroot(input_msg, clear_field=False,
+                                         parse_goma=False)
 
     with field_handler.copy_paths_in(input_msg, chroot.tmp, prefix=chroot.path):
       with chroot.tempdir() as tempdir, chroot.tempdir() as sync_tmp:
         with field_handler.sync_dirs(input_msg, sync_tmp, prefix=chroot.path):
+          # Parse the chroot and clear the chroot field in the input message.
+          chroot = field_handler.handle_chroot(input_msg)
+          # import pdb; pdb.set_trace();
           new_input = os.path.join(tempdir, self.REEXEC_INPUT_FILE)
           chroot_input = '/%s' % os.path.relpath(new_input, chroot.path)
           new_output = os.path.join(tempdir, self.REEXEC_OUTPUT_FILE)