Skip to content

Commit e832997

Browse files
authored
Remove unused resource-monitor code (#636)
See https://bugzilla.mozilla.org/show_bug.cgi?id=1906899
1 parent 10a0dcd commit e832997

File tree

2 files changed

+0
-109
lines changed

2 files changed

+0
-109
lines changed

src/taskgraph/run-task/run-task

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,64 +1026,6 @@ def install_pip_requirements(repositories):
10261026
run_required_command(b"pip-install", cmd)
10271027

10281028

1029-
def maybe_run_resource_monitoring():
1030-
"""Run the resource monitor if available.
1031-
1032-
Discussion in https://github.com/taskcluster/taskcluster-rfcs/pull/160
1033-
and https://bugzil.la/1648051
1034-
1035-
"""
1036-
if "MOZ_FETCHES" not in os.environ:
1037-
return
1038-
if "RESOURCE_MONITOR_OUTPUT" not in os.environ:
1039-
return
1040-
1041-
prefix = b"resource_monitor"
1042-
1043-
executable = "{}/resource-monitor/resource-monitor{}".format(
1044-
os.environ.get("MOZ_FETCHES_DIR"), ".exe" if IS_WINDOWS else ""
1045-
)
1046-
1047-
if not os.path.exists(executable) or not os.access(executable, os.X_OK):
1048-
print_line(prefix, b"%s not executable\n" % executable.encode("utf-8"))
1049-
return
1050-
args = [
1051-
executable,
1052-
"-process",
1053-
str(os.getpid()),
1054-
"-output",
1055-
os.environ["RESOURCE_MONITOR_OUTPUT"],
1056-
]
1057-
print_line(prefix, b"Resource monitor starting: %s\n" % str(args).encode("utf-8"))
1058-
# Avoid environment variables the payload doesn't need.
1059-
del os.environ["RESOURCE_MONITOR_OUTPUT"]
1060-
1061-
# Without CREATE_NEW_PROCESS_GROUP Windows signals will attempt to kill run-task, too.
1062-
process = subprocess.Popen(
1063-
args,
1064-
# Disable buffering because we want to receive output
1065-
# as it is generated so timestamps in logs are
1066-
# accurate.
1067-
bufsize=0,
1068-
stdout=subprocess.PIPE,
1069-
stderr=subprocess.STDOUT,
1070-
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP if IS_WINDOWS else 0,
1071-
cwd=os.getcwd(),
1072-
)
1073-
1074-
def capture_output():
1075-
fh = io.TextIOWrapper(process.stdout, encoding="latin1")
1076-
while True:
1077-
data = fh.readline().encode("latin1")
1078-
if data == b"":
1079-
break
1080-
print_line(prefix, data)
1081-
1082-
monitor_process = Thread(target=capture_output)
1083-
monitor_process.start()
1084-
return process
1085-
1086-
10871029
def _display_python_version():
10881030
print_line(
10891031
b"setup", b"Python version: %s\n" % platform.python_version().encode("utf-8")
@@ -1332,7 +1274,6 @@ def main(args):
13321274
b"%s is %s\n" % (k.encode("utf-8"), os.environ[k].encode("utf-8")),
13331275
)
13341276

1335-
resource_process = None
13361277
try:
13371278
if "MOZ_FETCHES" in os.environ:
13381279
fetch_artifacts()
@@ -1341,21 +1282,8 @@ def main(args):
13411282
# fetches to grab dependencies.
13421283
install_pip_requirements(repositories)
13431284

1344-
resource_process = maybe_run_resource_monitoring()
1345-
13461285
return run_command(b"task", task_args, cwd=args.task_cwd)
13471286
finally:
1348-
if resource_process:
1349-
print_line(b"resource_monitor", b"terminating\n")
1350-
if IS_WINDOWS:
1351-
# .terminate() on Windows is not a graceful shutdown, due to
1352-
# differences in signals. CTRL_BREAK_EVENT will work provided
1353-
# the subprocess is in a different process group, so this script
1354-
# isn't also killed.
1355-
os.kill(resource_process.pid, signal.CTRL_BREAK_EVENT)
1356-
else:
1357-
resource_process.terminate()
1358-
resource_process.wait()
13591287
fetches_dir = os.environ.get("MOZ_FETCHES_DIR")
13601288
if fetches_dir and os.path.isdir(fetches_dir):
13611289
print_line(b"fetches", b"removing %s\n" % fetches_dir.encode("utf-8"))

src/taskgraph/transforms/run/__init__.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -160,43 +160,6 @@ def set_label(config, tasks):
160160
yield task
161161

162162

163-
@transforms.add
164-
def add_resource_monitor(config, tasks):
165-
for task in tasks:
166-
if task.get("attributes", {}).get("resource-monitor"):
167-
worker_implementation, worker_os = worker_type_implementation(
168-
config.graph_config, task["worker-type"]
169-
)
170-
# Normalise worker os so that linux-bitbar and similar use linux tools.
171-
if worker_os:
172-
worker_os = worker_os.split("-")[0]
173-
if "win7" in task["worker-type"]:
174-
arch = "32"
175-
else:
176-
arch = "64"
177-
task.setdefault("fetches", {})
178-
task["fetches"].setdefault("toolchain", [])
179-
task["fetches"]["toolchain"].append(f"{worker_os}{arch}-resource-monitor")
180-
181-
if worker_implementation == "docker-worker":
182-
artifact_source = "/builds/worker/monitoring/resource-monitor.json"
183-
else:
184-
artifact_source = "monitoring/resource-monitor.json"
185-
task["worker"].setdefault("artifacts", [])
186-
task["worker"]["artifacts"].append(
187-
{
188-
"name": "public/monitoring/resource-monitor.json",
189-
"type": "file",
190-
"path": artifact_source,
191-
}
192-
)
193-
# Set env for output file
194-
task["worker"].setdefault("env", {})
195-
task["worker"]["env"]["RESOURCE_MONITOR_OUTPUT"] = artifact_source
196-
197-
yield task
198-
199-
200163
def get_attribute(dict, key, attributes, attribute_name):
201164
"""Get `attribute_name` from the given `attributes` dict, and if there
202165
is a corresponding value, set `key` in `dict` to that value."""

0 commit comments

Comments
 (0)