Revert "[autotest] Reduce sudo calls."
This reverts commit 91f39fe86cba0e20ca6d9085aedb10e9f33aad83.
Reason for revert: Broke SSP testing in staging lab.
Original change's description:
> [autotest] Reduce sudo calls.
>
> Remove unnecessary sudo calls from the zygote's setup code-path.
> Basically, anything that involves copying stuff into the container's
> filesystem requires sudo in a regular container, but not in a zygote.
>
> Some utility and other code required special-casing, so a sudo parameter
> was added to enable the zygote to do these operations without using sudo.
>
> This reduces the number of sudo calls seen in the functional test from
> 94 to 76. Similar savings ought to be seen in real tests.
>
> BUG=b:70818060
> TEST=shared_host_dir_unittest.py
> TEST=container_pool/pool_unittest.py
> TEST=container_pool/client_unittest.py
> TEST=container_pool/async_listener_unittest.py
> TEST=container_pool/service_unittest.py
> TEST=base_image_unittest.py
> TEST=lxc_config_unittest.py
> TEST=container_bucket_unittest.py
> TEST=container_unittest.py
> TEST=container_factory_unittest.py
> TEST=zygote_unittest.py
> TEST=lxc_functional_test.py
>
> Change-Id: Ib8bb1f3a227ed88dbabe3a3c0eb71080e6e696f7
> Reviewed-on: https://chromium-review.googlesource.com/837180
> Trybot-Ready: Ben Kwa <[email protected]>
> Reviewed-by: Ilja H. Friedel <[email protected]>
> Commit-Queue: Ilja H. Friedel <[email protected]>
> Tested-by: Ilja H. Friedel <[email protected]>
BUG=b:70818060
BUG=chromium:797142
Change-Id: If43d7d8e511fc0b4d4ffb34a8b272b7c9ab10953
Reviewed-on: https://chromium-review.googlesource.com/841430
Reviewed-by: Prathmesh Prabhu <[email protected]>
Tested-by: Prathmesh Prabhu <[email protected]>
diff --git a/site_utils/lxc/config.py b/site_utils/lxc/config.py
index 6ab5be1..833ed06 100644
--- a/site_utils/lxc/config.py
+++ b/site_utils/lxc/config.py
@@ -230,9 +230,9 @@
if 'mount' in c]
tmp_append = os.path.join(self.container.rootfs,
_APPEND_FOLDER.lstrip(os.path.sep))
- # Clear the _append_folder if it exists, and then recreate it.
- utils.run('sudo bash -c \'rm -rf "%s" && mkdir -p "%s"\'' %
- (tmp_append, tmp_append))
+ if lxc_utils.path_exists(tmp_append):
+ utils.run('sudo rm -rf "%s"' % tmp_append)
+ utils.run('sudo mkdir -p "%s"' % tmp_append)
def _deploy_config_pre_start(self, deploy_config):