[reclient] Add hostname to invocation ids

This is already covered in the PDD for googlers. We are already gathering hostnames in cloud monitoring mertrics


Bug: b/294945709
Change-Id: Idfb5b8d3b7cf64edd60092f6bd49a3f9f1950d15
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4848094
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Commit-Queue: Ben Segall <bentekkie@google.com>
changes/94/4848094/4
Ben Segall 2 years ago committed by LUCI CQ
parent 29282b581b
commit b64ee7f525

@ -12,6 +12,7 @@ Siso/Reclient builds.
import os
import re
import sys
import uuid
import reclient_helper
import siso
@ -50,6 +51,7 @@ def main(argv):
file=sys.stderr)
return 1
os.environ.setdefault("AUTONINJA_BUILD_ID", str(uuid.uuid4()))
with reclient_helper.build_context(argv, 'autosiso') as ret_code:
if ret_code:
return ret_code

@ -10,6 +10,7 @@ import contextlib
import hashlib
import os
import shutil
import socket
import subprocess
import sys
import time
@ -114,6 +115,14 @@ def auth_cache_status():
return "missing", "UNSPECIFIED"
def get_hostname():
hostname = socket.gethostname()
try:
return socket.gethostbyaddr(hostname)[0]
except socket.gaierror:
return hostname
def set_reproxy_metrics_flags(tool):
"""Helper to setup metrics collection flags for reproxy.
@ -126,7 +135,8 @@ def set_reproxy_metrics_flags(tool):
"""
autoninja_id = os.environ.get("AUTONINJA_BUILD_ID")
if autoninja_id is not None:
os.environ.setdefault("RBE_invocation_id", autoninja_id)
os.environ.setdefault("RBE_invocation_id",
"%s/%s" % (get_hostname(), autoninja_id))
os.environ.setdefault("RBE_metrics_project", "chromium-reclient-metrics")
os.environ.setdefault("RBE_metrics_table", "rbe_metrics.builds")
labels = "source=developer,tool=" + tool

@ -39,7 +39,8 @@ class NinjaReclientTest(trial_dir.TestCase):
os.chdir(self.previous_dir)
super(NinjaReclientTest, self).tearDown()
@unittest.mock.patch.dict(os.environ, {})
@unittest.mock.patch.dict(os.environ,
{'AUTONINJA_BUILD_ID': "SOME_RANDOM_ID"})
@unittest.mock.patch('subprocess.call', return_value=0)
@unittest.mock.patch('ninja.main', return_value=0)
@unittest.mock.patch('reclient_metrics.check_status', return_value=True)
@ -83,6 +84,7 @@ class NinjaReclientTest(trial_dir.TestCase):
hashlib.md5(
os.path.join(self.root_dir, "out", "a",
".reproxy_tmp").encode()).hexdigest()))
self.assertIn("/SOME_RANDOM_ID", os.environ["RBE_invocation_id"])
if sys.platform.startswith('win'):
self.assertEqual(
os.environ.get('RBE_server_address'),
@ -126,7 +128,8 @@ class NinjaReclientTest(trial_dir.TestCase):
]),
])
@unittest.mock.patch.dict(os.environ, {})
@unittest.mock.patch.dict(os.environ,
{'AUTONINJA_BUILD_ID': "SOME_RANDOM_ID"})
@unittest.mock.patch('subprocess.call', return_value=0)
@unittest.mock.patch('ninja.main', return_value=0)
@unittest.mock.patch('reclient_metrics.check_status', return_value=True)
@ -171,6 +174,7 @@ expiry: {
os.environ.get('RBE_proxy_log_dir'),
os.path.join(self.root_dir, "out", "a", ".reproxy_tmp", "logs"))
self.assertEqual(os.environ.get('RBE_cache_dir'), cache_dir)
self.assertIn("/SOME_RANDOM_ID", os.environ["RBE_invocation_id"])
if sys.platform.startswith('win'):
self.assertEqual(
os.environ.get('RBE_server_address'),
@ -214,7 +218,8 @@ expiry: {
]),
])
@unittest.mock.patch.dict(os.environ, {})
@unittest.mock.patch.dict(os.environ,
{'AUTONINJA_BUILD_ID': "SOME_RANDOM_ID"})
@unittest.mock.patch('subprocess.call', return_value=0)
@unittest.mock.patch('ninja.main', return_value=0)
@unittest.mock.patch('reclient_metrics.check_status', return_value=True)
@ -258,6 +263,7 @@ expiry: {
os.environ.get('RBE_proxy_log_dir'),
os.path.join(self.root_dir, "out", "a", ".reproxy_tmp", "logs"))
self.assertEqual(os.environ.get('RBE_cache_dir'), cache_dir)
self.assertIn("/SOME_RANDOM_ID", os.environ["RBE_invocation_id"])
if sys.platform.startswith('win'):
self.assertEqual(
os.environ.get('RBE_server_address'),

Loading…
Cancel
Save