Skip to content

Commit

Permalink
Bug 1311791 - Explicitly declare path to shared hg store; r=dustin
Browse files Browse the repository at this point in the history
332a08725ed0 changed the store path logic in a quick and crude manner.
The code could lead to multiple shared stores existing on a cache
if checkouts were in different parent directories.

This commit refactors the code to explicitly declare a path to the
shared hg store. This restores the behavior of ensuring there is only
a single shared store per cache.

MozReview-Commit-ID: 19Aa1QVrVQ8

--HG--
extra : rebase_source : f74c0ab9cba2bf18e335f24c86dd095335961723
  • Loading branch information
indygreg committed Oct 20, 2016
1 parent dc86fae commit 1deb8dd
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .taskcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ tasks:
GECKO_HEAD_REPOSITORY: '{{{url}}}'
GECKO_HEAD_REF: '{{revision}}'
GECKO_HEAD_REV: '{{revision}}'
HG_STORE_PATH: /home/worker/checkouts/hg-store

cache:
level-{{level}}-hg-shared: /home/worker/hg-shared
level-{{level}}-checkouts: /home/worker/checkouts

features:
Expand All @@ -86,7 +86,7 @@ tasks:

# Note: This task is built server side without the context or tooling that
# exist in tree so we must hard code the version
image: 'taskcluster/decision:0.1.6'
image: 'taskcluster/decision:0.1.7'

maxRunTime: 1800

Expand Down
6 changes: 1 addition & 5 deletions taskcluster/scripts/tester/run-wizard
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,10 @@ def clone():
print('revision is not specified for checkout')
return 1

# Put the shared stores as a sibling of the checkout directory. This ensures
# they are on the same cache.
share_base = os.path.normpath(os.path.join(os.path.dirname(dest), b'hg-shared'))

# TODO Bug 1301382 - pin hg.mozilla.org fingerprint.
call([
b'/usr/bin/hg', b'robustcheckout',
b'--sharebase', share_base
b'--sharebase', os.environ['HG_STORE_PATH'],
b'--purge',
b'--upstream', b'https://hg.mozilla.org/mozilla-unified',
revision_flag, revision,
Expand Down
3 changes: 2 additions & 1 deletion taskcluster/taskgraph/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ payload:
GECKO_HEAD_REPOSITORY: '{{{head_repository}}}'
GECKO_HEAD_REF: '{{head_ref}}'
GECKO_HEAD_REV: '{{head_rev}}'
HG_STORE_PATH: /home/worker/checkouts/hg-store

cache:
level-{{level}}-checkouts: /home/worker/checkouts
Expand All @@ -41,7 +42,7 @@ payload:

# Note: This task is built server side without the context or tooling that
# exist in tree so we must hard code the version
image: 'taskcluster/decision:0.1.6'
image: 'taskcluster/decision:0.1.7'

# Virtually no network or other potentially risky operations happen as part
# of the task timeout aside from the initial clone. We intentionally have
Expand Down
1 change: 1 addition & 0 deletions taskcluster/taskgraph/transforms/job/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def docker_worker_support_vcs_checkout(config, job, taskdesc):
'GECKO_BASE_REPOSITORY': config.params['base_repository'],
'GECKO_HEAD_REPOSITORY': config.params['head_repository'],
'GECKO_HEAD_REV': config.params['head_rev'],
'HG_STORE_PATH': '/home/worker/checkouts/hg-store',
})

# Give task access to hgfingerprint secret so it can pin the certificate
Expand Down
2 changes: 1 addition & 1 deletion testing/docker/decision/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.6
0.1.7
24 changes: 13 additions & 11 deletions testing/docker/recipes/run-task
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def run_and_prefix_output(prefix, args, extra_env=None):
return p.wait()


def vcs_checkout(source_repo, dest, base_repo=None, revision=None, branch=None):
def vcs_checkout(source_repo, dest, store_path,
base_repo=None, revision=None, branch=None):
# Specify method to checkout a revision. This defaults to revisions as
# SHA-1 strings, but also supports symbolic revisions like `tip` via the
# branch flag.
Expand Down Expand Up @@ -113,15 +114,11 @@ def vcs_checkout(source_repo, dest, base_repo=None, revision=None, branch=None):

hgmo_fingerprint = secret['secret']['fingerprints'].encode('ascii')

# Put the shared stores as a sibling of the checkout directory. This ensures
# they are on the same cache.
share_base = os.path.normpath(os.path.join(os.path.dirname(dest), b'hg-shared'))

args = [
b'/usr/bin/hg',
b'--config', b'hostsecurity.hg.mozilla.org:fingerprints=%s' % hgmo_fingerprint,
b'robustcheckout',
b'--sharebase', share_base,
b'--sharebase', store_path,
b'--purge',
]

Expand Down Expand Up @@ -268,16 +265,19 @@ def main(args):
# And that it is owned by the appropriate user/group.
os.chown(os.path.dirname(checkout), uid, gid)

# And ensure the shared store path (derived from the checkout path)
# exists and has proper permissions.
share_path = os.path.join(os.path.dirname(checkout), 'hg-shared')
# And ensure the shared store path exists and has proper permissions.
if 'HG_STORE_PATH' not in os.environ:
print('error: HG_STORE_PATH environment variable not set')
sys.exit(1)

store_path = os.environ['HG_STORE_PATH']
try:
os.makedirs(share_path)
os.makedirs(store_path)
except OSError as e:
if e.errno != errno.EEXIST:
raise

os.chown(share_path, uid, gid)
os.chown(store_path, uid, gid)

prepare_checkout_dir(args.vcs_checkout)
prepare_checkout_dir(args.tools_checkout)
Expand Down Expand Up @@ -307,6 +307,7 @@ def main(args):
os.environ['GECKO_HEAD_REV'] = vcs_checkout(
os.environ['GECKO_HEAD_REPOSITORY'],
args.vcs_checkout,
os.environ['HG_STORE_PATH'],
base_repo=base_repo,
revision=os.environ.get('GECKO_HEAD_REV'),
branch=os.environ.get('GECKO_HEAD_REF'))
Expand All @@ -319,6 +320,7 @@ def main(args):
if args.tools_checkout:
vcs_checkout(b'https://hg.mozilla.org/build/tools',
args.tools_checkout,
os.environ['HG_STORE_PATH'],
# Always check out the latest commit on default branch.
# This is non-deterministic!
branch=b'default')
Expand Down

0 comments on commit 1deb8dd

Please sign in to comment.