Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

INACTIVE - http://mzl.la/ghe-archive - Monitor and report replication lag for source code repositories mirrored in Phabricator.

License

Notifications You must be signed in to change notification settings

mozilla-conduit/phabricator-repo-monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Phabricator Repository Monitor

This program monitors source code repositories that have been mirrored in Phabricator.

It measures and reports the replication delay between the mirrored repository and its upstream repository.


How it works

The program runs an internal scheduler that triggers a check-and-report routine every five minutes.

To check the Phabricator repository replication delay the program reads Mercurial repository push messages off of the Mozilla Pulse hgpush message queue. There is one hgpush message for each push made to the upstream repository. Each push contains multiple commits. Pushes and the commits inside them are in order, oldest to newest.

For each commit in an upstream push the program checks for the existence of that commit in the downstream Phabricator repository mirror. If all commits in the push exist in Phabricator then we assume the push has been fully mirrored to Phabricator. The push message is removed from the queue, a replication delay of zero seconds is reported, and the program moves on to the next push message.

If one or more commits in a push is missing from Phabricator then we assume the Phabricator repository replication program is still working to catch up to the upstream repo. Our program reports the replication delay as the difference between the current time and the time the push to the source repo took place. The delay-checking routine exits early and the push message is left at the head of the queue for the next check-and-report run.


Setup

You should use pyenv to make sure you are using the same Python version listed in the Program's Pipfile.

This project's dependencies are managed with Pipenv. After you have installed pipenv on your system run the following in the project root:

$ pipenv install

You will need to create an account on Mozilla Pulse to collect messages about hgpush events.

This program is designed to run on Heroku and follows the Heroku Architectural Principles. It reads its settings from environment variables.

See the file dotenv.example.txt in the project root for possible values. These values must be present in your local and/or heroku execution environments:

$ cp dotenv.example.txt .env
$ vim .env
# Add your personal environment's configuration

Run the following command to check that everything works. It won't send any data:

$ env PYTHONPATH=src pipenv run bin/report-lag --no-send

Development

Environment setup

Install the development dependencies with pipenv:

$ pipenv install --dev

Hacking

Code formatting is done with black.

Push event messages are read from a Pulse message queue. You can inspect a live hgpush message queue with Pulse Inspector.

Messages use the hgpush message format.

Push events are generated from the mercurial repo pushlogs.

Testing

Automated tests

The unit test suite can be run with pytest:

$ pipenv run pytest

Manual/Smoke testing

You can smoke-test the program as follows:

$ env PYTHONPATH=src pipenv run bin/report-lag --no-send --debug

Usage

To get command-line help run the following:

$ env PYTHONPATH=src pipenv run bin/report-lag --help

This script should be run on a Heroku standard dyno.

About

INACTIVE - http://mzl.la/ghe-archive - Monitor and report replication lag for source code repositories mirrored in Phabricator.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages