From 6ecb76149d9f70697a8db40dc466d58b63d4fc4d Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Thu, 9 Mar 2023 12:22:53 -0700 Subject: [PATCH] repo_utils: Add instrumentation for bootstrap time And fix a couple of linter errors. Signed-off-by: Zack Cerza --- teuthology/exporter.py | 5 +++++ teuthology/repo_utils.py | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/teuthology/exporter.py b/teuthology/exporter.py index 776cc873b7..ef1c3229da 100644 --- a/teuthology/exporter.py +++ b/teuthology/exporter.py @@ -200,6 +200,11 @@ TaskTime = Summary( ["name", "phase"], ) +BootstrapTime = Summary( + "teuthology_bootstrap_duration_seconds", + "Time spent running teuthology's bootstrap script", +) + def main(args): exporter = TeuthologyExporter(interval=int(args["--interval"])) diff --git a/teuthology/repo_utils.py b/teuthology/repo_utils.py index 1fe189dfbe..93ee225a33 100644 --- a/teuthology/repo_utils.py +++ b/teuthology/repo_utils.py @@ -5,6 +5,8 @@ import shutil import subprocess import time +import teuthology.exporter as exporter + from teuthology import misc from teuthology.util.flock import FileLock from teuthology.config import config @@ -438,6 +440,7 @@ def fetch_teuthology(branch, commit=None, lock=True): def bootstrap_teuthology(dest_path): + with exporter.BootstrapTime.time(): log.info("Bootstrapping %s", dest_path) # This magic makes the bootstrap script not attempt to clobber an # existing virtualenv. But the branch's bootstrap needs to actually @@ -445,11 +448,15 @@ def bootstrap_teuthology(dest_path): env = os.environ.copy() env['NO_CLOBBER'] = '1' cmd = './bootstrap' - boot_proc = subprocess.Popen(cmd, shell=True, cwd=dest_path, env=env, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - universal_newlines=True) - out, err = boot_proc.communicate() + boot_proc = subprocess.Popen( + cmd, shell=True, + cwd=dest_path, + env=env, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + universal_newlines=True + ) + out, _ = boot_proc.communicate() returncode = boot_proc.wait() log.info("Bootstrap exited with status %s", returncode) if returncode != 0: -- 2.39.5