Skip to content

Commit

Permalink
Bug 1505086: use mach python to submit build telemetry r=ted
Browse files Browse the repository at this point in the history
While attempting to improve the build telemetry submission
logic, I found a bug in the way telemetry submission
works. Essentially the submission script was failing to
import any of the required packages (specifically
`mozbuild.telemetry` in this case) as the method used to
modify path was incorrect and the script was running outside
of the virtualenv. The invocation is also sending stdout
and stderr to `/dev/null`, making this problem even less obvious.
When I fixed the path modifications, I realized that `mozbuild`
imports will require a long chain of other imports
(and transitively, more `sys.path` modifications)
such as `which`, `mach`, `mozautomation`, etc to complete.

When I tested the submission script, I did so by running
`mach python build/submit_telemetry_data.py`, which runs the
script in a virtualenv with all required packages installed.
That's likely part of the reasons I overlooked this issue in testing.
Rather than go through the process of importing every dependency
of `mozbuild`, this commit changes the invocation of the submission
script to go through `mach python`. Things seem to work as
expected with this change.

Differential Revision: https://phabricator.services.mozilla.com/D11278
  • Loading branch information
cgsheeh committed Nov 12, 2018
1 parent 46a0410 commit 3c0613a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
4 changes: 3 additions & 1 deletion build/mach_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,10 @@ def post_dispatch_handler(context, handler, instance, result,
if random.randint(1, TELEMETRY_SUBMISSION_FREQUENCY) != 1:
return

machpath = os.path.join(instance.topsrcdir, 'mach')
with open(os.devnull, 'wb') as devnull:
subprocess.Popen([sys.executable,
subprocess.Popen([machpath, 'python',
'--no-virtualenv',
os.path.join(topsrcdir, 'build',
'submit_telemetry_data.py'),
get_state_dir()[0]],
Expand Down
8 changes: 0 additions & 8 deletions build/submit_telemetry_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
import os
import sys

HERE = os.path.abspath(os.path.dirname(__file__))
PYTHIRDPARTY = os.path.join(HERE, '..', 'third_party', 'python')

# Add some required files to $PATH to ensure they are available
sys.path.append(os.path.join(HERE, '..', 'python', 'mozbuild', 'mozbuild'))
sys.path.append(os.path.join(PYTHIRDPARTY, 'requests'))
sys.path.append(os.path.join(PYTHIRDPARTY, 'voluptuous'))

import requests
import voluptuous
import voluptuous.humanize
Expand Down

0 comments on commit 3c0613a

Please sign in to comment.