Repository navigation
Support git try pushes in the test scheduling endpoint - #7694
Conversation
|
@ahal I'm not expecting you to review all of this, but just a high level review of the approach to make sure it is sound. |
1704df0 to
875db33
Compare
|
Sweet thanks, I had started an agent on this but it'll be much better with you driving it over me |
I think this works, but it might be better to get this out of the Decision task's parameters.yml file instead. Mainly because in the future I'm planning to replace |
ahal
left a comment
There was a problem hiding this comment.
Thanks, yes the overall changes look sound!
| after=tenacity.after_log(logger, logging.DEBUG), | ||
| retry=tenacity.retry_if_exception_type(subprocess.CalledProcessError), | ||
| ) | ||
| def _fetch_git_commit(repo_dir: str, url: str, rev: str, depth: int | None) -> None: |
There was a problem hiding this comment.
I recall a separate conversation about using run-task in reviewbot or similar. Seems like this might be another use case for it. I guess what we really want is a Git equivalent of robustcheckout.py (so just the cloning pieces of run-task without all the other Taskcluster stuff).
Not something to block or anything, just an observation.
| ) | ||
|
|
||
| # The git try repositories (as Treeherder projects), with their GitHub repository. | ||
| GIT_TRY_REPOSITORIES = {"firefox-dev": "mozilla-firefox/firefox-dev"} |
There was a problem hiding this comment.
Might as well also add mozilla-firefox/firefox-dev-secure while we're at it.
This wouldn't be possible with the current architecture: the decision task depends on bugbug answer, and so bugbug can't depend on the decision task artifact. |
repository.get_git_patch fetches the commits from a base revision to a head revision of a remote repository into a local repository, and returns them in git format-patch style, so they can be imported in a Mercurial repository. Only the commits and trees are fetched (the file contents are fetched when needed), and the base is fetched with a depth of 1, so that the head fetch stops at it and doesn't bring its history. The local repository is reused: the only ref is to the last base, so that only the trees which changed are fetched with the next base, and the other commits are pruned when the repository is garbage collected.
As the commits are fetched without the file contents, git format-patch fetched the contents of the changed files one by one, with a request for each of them. They are now fetched before generating the patch, with a single request for up to 500 of them. On 30 commits of mozilla-firefox/firefox changing 199 files, getting the patch takes 12.9 seconds instead of 28.1.
The decision task of pushes to the firefox-dev git try repository requests /push/firefox-dev/<rev>/schedules, which failed as the push was looked for on hg.mozilla.org. For these pushes, the commits are fetched from GitHub with git, from the base revision `mach try` records in the try_task_config.json of the push (as GitHub reports a null base for a push creating a branch), into a git repository reused across jobs. They are then imported on top of the base in the local Mercurial repository, so that they are analyzed in the same way as the commits of hg try pushes. The base is pulled from autoland unless it is already local, as for the patch endpoint, with which the code is shared. Pushes without a base revision in their try_task_config.json, or with a base which isn't on autoland, are not supported.
The Pulse listener requested the test scheduling of hg try and autoland pushes when they were pushed, so that it was being computed or already computed when the decision task requested it, but not the one of git try pushes. It now also listens to the pushes Taskcluster publishes for the git try repositories (on exchange/taskcluster-github/v1/push, when it receives them from GitHub, before the decision task runs), skipping branch deletions and tags.
The requests to GitHub for git try pushes (the try_task_config.json of the push, and the git fetches, including the lazy fetches of file contents when the patch is generated) are now authenticated with BUGBUG_GITHUB_TOKEN when it is set, so that the pushes to private repositories can be fetched given a token with read access to them. The token is given to git as an HTTP header configured through the environment, so that it doesn't appear on command lines, in error messages or in the configuration of the local repository.
88c264f to
054b5fd
Compare
The decision task of pushes to the
firefox-devgit try repository requests/push/firefox-dev/<rev>/schedules(e.g. for https://treeherder.mozilla.org/jobs?repo=firefox-dev&revision=042402d29da9a5735e2062c20644cf4da966be95), which fails as the push is looked for on hg.mozilla.org. This adds support for the pushes tofirefox-devand to the privatefirefox-dev-secure.For these pushes:
try_task_config.jsonof the push: GitHub reports a null base for a push creating a branch, somach tryrecords it there (parameters.base_rev).BUGBUG_GIT_REPO_DIR). The base is fetched with a depth of 1, so the head fetch stops at it, and only commits and trees are fetched, then the contents of the changed files in a single request. The only ref is to the last base, so that GitHub only sends the trees which changed with the next base (1-3 MB instead of ~35 MB for the whole tree), and git's gc prunes the other commits.git format-patchand imported on top of the base (mapped with Lando'sgit2hg, and pulled from autoland unless it is already local, as for the patch endpoint) in the local Mercurial repository, so they are analyzed exactly like the commits of hg try pushes, including skipping the commits which only addtry_task_config.json.The Pulse listener also requests the scheduling of git try pushes as soon as they are pushed, as it does for hg try pushes, from the push messages Taskcluster publishes on
exchange/taskcluster-github/v1/pushwhen it receives them from GitHub (before the decision task runs).No GitHub API is used. When
BUGBUG_GITHUB_TOKENis set, the requests to GitHub (try_task_config.jsonand the git fetches) are authenticated with it, whichfirefox-dev-securerequires: the token needs read access to it. It is given to git through the environment (http.extraheader), so it doesn't appear on command lines, in error messages or in the repository configuration.Tested on 4 recent firefox-dev pushes, from a new git repository and a mozilla-central clone: the stack contains the commits of the push with the same descriptions (except the blank line after the title, which
hg importdrops), the same files, and the same contents of the changed files at the head. Getting the patch takes ~4s per push, and the whole import 17-26s, most of it updating the working directory to the base (#7695 removes that). Fetching the file contents at once brings 30 commits of mozilla-firefox/firefox changing 199 files from 28.1s to 12.9s.firefox-dev-securewasn't tested.Not supported (the job returns NOK): pushes without
base_revin theirtry_task_config.json(not pushed withmach try) and, as for the patch endpoint, bases which aren't on autoland (e.g. beta).The taskgraph also needs
firefox-devandfirefox-dev-secureinSUPPORTED_PROJECTS(taskcluster/gecko_taskgraph/util/bugbug.py), asmach try autopushes to them currently fail before querying bugbug.