Re-land "Really don't pass default cache directory to subprocesses."
This re-lands CL:43250 which was reverted in CL:43252.
Original CL description is below.
It does not make sense for subprocesses to inherit the default cache-dir.
Consider the following case:
- cbuildbot is executed from /b/build/slave/x86-generic-paladin/build
- cbuildbot re-executes inside /b/cbuild/external_master
Currently, in this case, the re-executed cbuildbot uses
/b/build/slave/x86-generic-paladin/build/.cache, which is just plain wrong.
cbuildbot should use its local cache dir and not inherit it from parents.
To fix this we need to both remove an environment variable and avoid using
the sourceroot to calculate the cache directory.
BUG=chromium-os:37908, chromium-os:36324
TEST=Run cbuildbot and really verify right cache-dir is used now.
Change-Id: I5f92fcbea7437ef731fee6d437834d6dee103686
Reviewed-on: https://gerrit.chromium.org/gerrit/43258
Reviewed-by: Peter Mayo <petermayo@chromium.org>
Tested-by: David James <davidjames@chromium.org>
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py
index 41a5bd6..65531f4 100644
--- a/scripts/cbuildbot.py
+++ b/scripts/cbuildbot.py
@@ -241,6 +241,10 @@
vp_file = sync_instance.SaveValidationPool()
args += ['--validation_pool', vp_file]
+ # Reset the cache dir so that the child will calculate it automatically.
+ if not self.options.cache_dir_specified:
+ commandline.BaseParser.ConfigureCacheDir(None)
+
# Re-run the command in the buildroot.
# Finally, be generous and give the invoked cbuildbot 30s to shutdown
# when something occurs. It should exit quicker, but the sigterm may
@@ -680,9 +684,7 @@
parser.values.chrome_rev = value
-def FindCacheDir(parser, options):
- if constants.SHARED_CACHE_ENVVAR in os.environ:
- return commandline.OptionParser.FindCacheDir(parser, options)
+def FindCacheDir(_parser, _options):
return None
@@ -1041,14 +1043,15 @@
raise Exception('Could not find repo checkout at %s!'
% options.sourceroot)
- # Ensure we have a workable cachedir from this point forward.
+ # Because the default cache dir depends on other options, FindCacheDir
+ # always returns None, and we setup the default here.
if options.cache_dir is None:
# Note, options.sourceroot is set regardless of the path
# actually existing.
- if os.path.exists(options.sourceroot):
- options.cache_dir = os.path.join(options.sourceroot, '.cache')
- elif options.buildroot is not None:
+ if options.buildroot is not None:
options.cache_dir = os.path.join(options.buildroot, '.cache')
+ elif os.path.exists(options.sourceroot):
+ options.cache_dir = os.path.join(options.sourceroot, '.cache')
else:
options.cache_dir = parser.FindCacheDir(parser, options)
options.cache_dir = os.path.abspath(options.cache_dir)