Skip to content

Remove old nix hack to read /etc/hosts for taskcluster proxy. #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 1 addition & 30 deletions tools/code_coverage_tools/taskcluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import copy
import os
import re

import structlog
import taskcluster
Expand All @@ -20,26 +19,6 @@
TASKCLUSTER_DATE_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"


def read_hosts():
"""
Read /etc/hosts to get hostnames
on a Nix env (used for taskclusterProxy)
Only reads ipv4 entries to avoid duplicates
"""
out = {}
regex = re.compile(r"([\w:\-\.]+)")
for line in open("/etc/hosts").readlines():
if ":" in line: # only ipv4
continue
x = regex.findall(line)
if not x:
continue
ip, names = x[0], x[1:]
out.update(dict(zip(names, [ip] * len(names))))

return out


class TaskclusterConfig(object):
"""
Local configuration used to access Taskcluster service and objects
Expand Down Expand Up @@ -90,16 +69,8 @@ def auth(self, client_id=None, access_token=None):
self.options["rootUrl"] = "https://taskcluster.net"

else:
# Get taskcluster proxy host
# as /etc/hosts is not used in the Nix image (?)
hosts = read_hosts()
if "taskcluster" not in hosts:
raise Exception("Missing taskcluster in /etc/hosts")

# Load secrets from TC task context
# with taskclusterProxy
root_url = f"http://{hosts['taskcluster']}"

root_url = "http://taskcluster"
logger.info("Taskcluster Proxy enabled", url=root_url)
self.options["rootUrl"] = root_url

Expand Down