hgmo: stop supporting bundleclone for IP address filtering (
bug 1352494); r?glob
We have custom code in the hgmo extension for modifying the behavior
of clonebundles and bundleclone manifest serving to filter and
re-prioritize entries depending on the source IP address.
Now that we don't care about bundleclone manifests, we can remove
support for bundleclone from this extension.
It isn't obvious from the patch, but the "stream=" syntax was only
used by bundleclone. clonebundles uses that BUNDLESPEC syntax for
similar functionality.
MozReview-Commit-ID: 8v2Z6pqHa7E
--- a/hgext/hgmo/__init__.py
+++ b/hgext/hgmo/__init__.py
@@ -607,36 +607,28 @@ def mozbuildinfocommand(ui, repo, *paths
# TODO send data to templater.
# Use stable output and indentation to make testing easier.
ui.write(json.dumps(d, indent=2, sort_keys=True))
ui.write('\n')
return
-def clonebundleswireproto(orig, repo, proto):
- """Wraps wireproto.clonebundles."""
- return processbundlesmanifest(repo, proto, orig(repo, proto))
-
-
-def bundleclonewireproto(orig, repo, proto):
- """Wraps wireproto.bundles."""
- return processbundlesmanifest(repo, proto, orig(repo, proto))
-
-
-def processbundlesmanifest(repo, proto, manifest):
- """Processes a bundleclone/clonebundles manifest.
+def processbundlesmanifest(orig, repo, proto):
+ """Wraps wireproto.clonebundles.
We examine source IP addresses and advertise URLs for the same
AWS region if the source is in AWS.
"""
# Delay import because this extension can be run on local
# developer machines.
import ipaddress
+ manifest = orig(repo, proto)
+
if not isinstance(proto, webproto):
return manifest
awspath = repo.ui.config('hgmo', 'awsippath')
if not awspath:
return manifest
# Mozilla's load balancers add a X-Cluster-Client-IP header to identify the
@@ -671,28 +663,22 @@ def processbundlesmanifest(repo, proto,
# No manifest entries for this region. Ignore match and try others.
if not filtered:
continue
# We prioritize stream clone bundles to AWS clients because they are
# the fastest way to clone and we want our automation to be fast.
def mancmp(a, b):
packed = 'BUNDLESPEC=none-packed1'
- stream = 'stream='
if packed in a and packed not in b:
return -1
if packed in b and packed not in a:
return 1
- if stream in a and stream not in b:
- return -1
- if stream in b and stream not in a:
- return 1
-
return 0
filtered = sorted(filtered, cmp=mancmp)
# We got a match. Write out the filtered manifest (with a trailing newline).
filtered.append('')
return '\n'.join(filtered)
@@ -751,22 +737,17 @@ def extsetup(ui):
revset.safesymbols.add('reviewer')
revset.symbols['automationrelevant'] = revset_automationrelevant
revset.safesymbols.add('automationrelevant')
# Install IP filtering for bundle URLs.
# Build-in command from core Mercurial.
- extensions.wrapcommand(wireproto.commands, 'clonebundles', clonebundleswireproto)
-
- # Legacy bundleclone command. Need to support until all clients run
- # 3.6+.
- if 'bundles' in wireproto.commands:
- extensions.wrapcommand(wireproto.commands, 'bundles', bundleclonewireproto)
+ extensions.wrapcommand(wireproto.commands, 'clonebundles', processbundlesmanifest)
entry = extensions.wrapcommand(commands.table, 'serve', servehgmo)
entry[1].append(('', 'hgmo', False,
'Run a server configured like hg.mozilla.org'))
wrapper = ui.config('hgmo', 'mozbuildinfowrapper')
if wrapper:
if '"' in wrapper or "'" in wrapper: