Bug 1505086: use `mach python` to submit build telemetry r=ted

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Connor Sheehan 2018-11-12 14:57:57 +00:00
Родитель 966aaae6ae
Коммит dde148da52
2 изменённых файлов: 3 добавлений и 9 удалений

Просмотреть файл

@ -282,8 +282,10 @@ def bootstrap(topsrcdir, mozilla_dir=None):
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]],

Просмотреть файл

@ -10,14 +10,6 @@ import logging
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