Backed out changeset efb782988830 (bug 1596479) for wrench bustage (KeyError: 'region'). CLOSED TREE

--HG--
extra : source : a1338baeaa0ae3f6c392d7e799c12c823681c146
This commit is contained in:
Brindusan Cristian 2019-11-21 00:45:18 +02:00
Родитель ecff1d58fe
Коммит 92d83fc37e
1 изменённых файлов: 12 добавлений и 23 удалений

Просмотреть файл

@ -538,28 +538,14 @@ def resolve_checkout_url(base_repo, head_repo):
The config will be of the form:
{
"aws/us-west-2": { # key built from `TASKCLUSTER_WORKER_LOCATION` variable
"us-west-2": { # value of `TASKCLUSTER_WORKER_GROUP`
"rate": 0.5,
"domain": "us-west-2.hgmointernal.net"
},
"google/us-central1": {...}
"us-east-1": {...}
}
"""
worker_location = os.getenv('TASKCLUSTER_WORKER_LOCATION')
if not worker_location:
print_line(b'vcs', b'TASKCLUSTER_WORKER_LOCATION environment variable not set; '
b'using public hg.mozilla.org service\n')
return base_repo, head_repo
try:
worker_location = json.loads(worker_location)
except json.JSONDecodeError:
print_line(b'vcs', b'Could not decode TASKCLUSTER_WORKER_LOCATION environment variable '
b'as JSON. Content: %s\n' % worker_location)
print_line(b'vcs', b'using public hg.mozilla.org service\n')
return base_repo, head_repo
config_key = '%(cloud)s/%(region)s' % worker_location
region = os.getenv('TASKCLUSTER_WORKER_GROUP')
try:
print_line(b'vcs', b'fetching hgmointernal config from %s\n' %
@ -570,14 +556,17 @@ def resolve_checkout_url(base_repo, head_repo):
hgmointernal_config = json.loads(res.read().decode('utf-8'))['secret']
# Use public hg service if region not yet supported
if config_key not in hgmointernal_config:
print_line(b'vcs', b'region %s not yet supported; using public '
b'hg.mozilla.org service\n' % config_key.encode('utf-8'))
if region not in hgmointernal_config:
if region:
print_line(b'vcs', b'region %s not yet supported; using public '
b'hg.mozilla.org service\n' % region.encode('utf-8'))
else:
print_line(b'vcs', b'unspecified region; using public '
b'hg.mozilla.org service\n')
return base_repo, head_repo
# Only send a percentage of traffic to the internal mirror
rate = float(hgmointernal_config[config_key]['rate'])
rate = float(hgmointernal_config[region]['rate'])
if random.random() > rate:
print_line(b'vcs', b'hgmointernal rate miss; using '
@ -587,7 +576,7 @@ def resolve_checkout_url(base_repo, head_repo):
print_line(b'vcs', b'hgmointernal rate hit; cloning from '
b'private hgweb mirror\n')
mirror_domain = hgmointernal_config[config_key]['domain']
mirror_domain = hgmointernal_config[region]['domain']
if base_repo and base_repo.startswith('https://hg.mozilla.org'):
base_repo = base_repo.replace('hg.mozilla.org', mirror_domain, 1)