Reland "Add git_cache epoch to bot_update output.properties"

This reverts commit ede859f9ee.

Reason for revert: This change includes a fix for the missing path issue. if the `cache_path` doesn't exist, it runs os.mkdirs before setting the cache epoch marker.

Original change's description:
> Revert "Add git_cache epoch to bot_update output.properties"
>
> This reverts commit 867d3267c1.
>
> Reason for revert: breaks some builders, https://crbug.com/1448769#c5
>
> Original change's description:
> > Add git_cache epoch to bot_update output.properties
> >
> > This change adds git cache's epoch timestamp to bot_update's output.properties. It achieves this by adding a marker file to the cache directory which stores the epoch time.
> >
> > Design: go/query-bot-update-cache-age
> >
> > Bug: 1448769
> > Change-Id: I610c6bca5ced7e2a0fe3ee8570decf0f135fe54c
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4563726
> > Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
> > Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
>
> Bug: 1448769
> Change-Id: I29db9ac364a9cf1d615b00ed75c1346e56b3f3b6
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4582291
> Commit-Queue: Gavin Mak <gavinmak@google.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>

Bug: 1448769
Change-Id: Ia6fd5b27f7556dd81f65011364506d3aa535de62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4583007
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
changes/07/4583007/3
Aravind Vasudevan 2 years ago committed by LUCI CQ
parent f0f66e936f
commit 12b45d719a

@ -1044,6 +1044,22 @@ def checkout(options, git_slns, specs, revisions, step_text):
ver = git('version').strip()
print('Using %s' % ver)
# Get the epoch of the git cache from a cache epoch marker file. If this file
# does not exist, create one with the current timestamp.
cache_epoch_marker_path = os.path.join(options.git_cache_dir, '.cache_epoch')
if os.path.isfile(cache_epoch_marker_path):
with open(cache_epoch_marker_path) as f:
cache_epoch = f.readline().strip()
else:
# This ensures the cache path exists. This is a noop if the path already
# exists. See crbug.com/1448769#c8.
os.makedirs(options.git_cache_dir, exist_ok=True)
with open(cache_epoch_marker_path, 'w') as f:
cache_epoch = int(time.time())
print(cache_epoch, file=f)
print('git_cache epoch: {}'.format(datetime.fromtimestamp(int(cache_epoch))))
try:
protocol = git('config', '--get', 'protocol.version')
print('Using git protocol version %s' % protocol)
@ -1133,15 +1149,18 @@ def checkout(options, git_slns, specs, revisions, step_text):
revision_mapping['got_revision'] = first_sln
manifest = create_manifest()
got_revisions = parse_got_revision(manifest, revision_mapping)
properties = parse_got_revision(manifest, revision_mapping)
if not got_revisions:
if not properties:
# TODO(hinoka): We should probably bail out here, but in the interest
# of giving mis-configured bots some time to get fixed use a dummy
# revision here.
got_revisions = { 'got_revision': 'BOT_UPDATE_NO_REV_FOUND' }
properties = {'got_revision': 'BOT_UPDATE_NO_REV_FOUND'}
#raise Exception('No got_revision(s) found in gclient output')
# Add git cache age to the output.properties
properties['git_cache_epoch'] = cache_epoch
# Tell recipes information such as root, got_revision, etc.
emit_json(options.output_json,
did_run=True,
@ -1149,7 +1168,7 @@ def checkout(options, git_slns, specs, revisions, step_text):
patch_root=options.patch_root,
step_text=step_text,
fixed_revisions=revisions,
properties=got_revisions,
properties=properties,
manifest=manifest)

Loading…
Cancel
Save