Blame docs/buildsys/reimzul.md

12bb45
# Reimzul CentOS 7 distro build system
12bb45
12bb45
!!! note
12bb45
    Reimzul is a distributed build system that is used to build CentOS Linux up to (and including CentOS 7).
12bb45
    For CentOs 8/8-stream/9-stream and beyond, see other koji system
12bb45
12bb45
## Reimzul overview
12bb45
![reimzul](../img/reimzul.png)
12bb45
12bb45
Reimzul consists only of some python scripts, that are used as wrappers around mock.
12bb45
12bb45
The following components are used to orchestrate the builds and notifications:
12bb45
12bb45
 * [beanstalkd](http://kr.github.io/beanstalkd/) : used as build queues, per arches
12bb45
 * [stunnel](http://www.stunnel.org/) : all components are using TLS connections , so including workers connecting to beanstalkd, to "watch" the queues and pick the build jobs landing in those queues, as well as for http (to retrieve the src.rpm to build) and then also for rsync (transferring artifacts - logs,rpm - to bstore node)
12bb45
 * MQTT : python-paho-mqtt : sending results to a mqtt broker, with other subscribers used for notifications (including IRC)
12bb45
 * [MongoDB](http://www.mongodb.org) : just use as document store to load build results and so be able to track/query build history
12bb45
12bb45
## Controller
12bb45
This is the node that runs beanstalkd for the various tubes/queues
12bb45
To submit a pkg, we have two options:
12bb45
12bb45
 * build a .src.rpm, uploaded under /srv/reimzul/incoming and call (local) reimzul_submit.py script (see above)
12bb45
 * remotely trigger a build from git (including branch/tag/commit id) through reimzul_client (see above)
12bb45
12bb45
Example when willing to submit same src.rpm (already uploaded !) to multiple arches :
12bb45
```
12bb45
for arch in x86_64 aarch64 armhfp ; do /srv/reimzul/code/reimzul_submit.py -s time-1.7-45.el7.src.rpm -d .el7 -a $arch -t c7.1708.u ; done
12bb45
```
12bb45
Important to know that there is no need to submit for i386 : it will be done automatically in parallel on the builder doing the x86_64 build, with the same timestamp
12bb45
12bb45
The controller has also a dispatcher worker (msg_dispatcher.py) that watches the notify tube, and will :
12bb45
12bb45
 * send mails to specific rcpts for each failed/successful build
12bb45
 * log to /var/log/reimzul/reimzul.log
12bb45
 * add each job to local mongodb instance
12bb45
 * also send json payload over mqtt (so then various subscribers can reuse those payloads, including for example for irc notifications)
12bb45
12bb45
To control those notifications, reimzul uses a config file /etc/reimzul/reimzul.ini (see reimzul.ini.sample for reference)
12bb45
12bb45
### Processes :
12bb45
12bb45
  * reimzul-notifier.py (sending notifications for build results, log, mqtt, mails)
12bb45
  * reimzul-mqtt-pub.py (process subscribed to some topic to allow remote builds, and that process will retrieve automatically from git and submit)
12bb45
12bb45
One reimzul notifier worker is enough to send notifications
12bb45
```
12bb45
cp systemd/reimzul-notifier.service /etc/systemd/system/
12bb45
systemctl daemon-reload
12bb45
systemctl enable reimzul-notifier --now
12bb45
12bb45
```
12bb45
12bb45
One reimzul mqtt subscriber worker is enough to wait for incoming build requests
12bb45
```
12bb45
cp systemd/reimzul-mqtt-sub.service /etc/systemd/system/
12bb45
systemctl daemon-reload
12bb45
systemctl enable reimzul-mqtt-sub --now
12bb45
12bb45
```
12bb45
12bb45
12bb45
12bb45
## Builders (workers) : 
12bb45
12bb45
These nodes are the ones that :
12bb45
12bb45
 * watch for jobs in $arch (exception being x86_64, watching also i386 tube)
12bb45
 * download the src.rpm from controller (stunnel)
12bb45
 * submit it to mock
12bb45
 * upload results to bstore node (central http repo holding all the repositories)
12bb45
 * sending results back in notify tube
12bb45
12bb45
### Processes :
12bb45
12bb45
 * reimzul_worker.py 
12bb45
12bb45
You can launch as many workers/builder threads you want : there is a .service systemd unit file (see systemd/reimzul-worker@.service) that you can then launch multiple times. For example, let's assume that we want 4 parallel workers : 
12bb45
```
12bb45
cp systemd/reimzul-worker@.service /etc/systemd/system/
12bb45
systemctl daemon-reload
12bb45
for i in {1..4} ; do systemctl enable reimzul-worker@${i} --now; done
12bb45
12bb45
```
12bb45
12bb45
## Bstore :
12bb45
12bb45
Central storage node that will accept all build artifacts under specific target repos.
12bb45
Worth noting that all communication, including rsyncd, happen over tls (through stunnel)
12bb45
It has also a worker itself, just watching the "createrepo" channel.
12bb45
When a build finishes and has a successful build, one job is added to the createrepo tube (you can have multiple parallel workers for this too) and repo metadata is launched through createrepo_c, with multiple workers per process and cache directory
12bb45
12bb45
### Processes
12bb45
12bb45
 * tosign_worker.py (will collect built pkgs in a staging area, waiting for pkgs to be then signed)
12bb45
 * repogen_worker.py (will regenerate repodata on each successful build)
12bb45
12bb45
You can launch as many repogen workers threads as you want : there is a .service systemd unit file (see systemd/reimzul-repoogen-worker@.service) that you can then launch multiple times. For example, let's assume that we want 3 parallel workers : 
12bb45
```
12bb45
cp systemd/reimzul-repogen-worker@.service /etc/systemd/system/
12bb45
systemctl daemon-reload
12bb45
for i in {1..3} ; do systemctl enable reimzul-repogen-worker@${i} --now; done
12bb45
12bb45
```
12bb45
12bb45
One signer worker is enough (it will just copy the rpm files in a staging area, waiting to be collected for signing)
12bb45
```
12bb45
cp systemd/reimzul-signer.service /etc/systemd/system/
12bb45
systemctl daemon-reload
12bb45
systemctl enable reimzul-signer --now
12bb45
12bb45
```
12bb45
12bb45
## Clients
12bb45
12bb45
### Local client (on the controller, so need priv and local access)
12bb45
12bb45
Once a .src.rpm is built and available under /srv/reimzul/incoming, you can submit builds to Reimzul is to launch reimzul_submit.py : 
12bb45
```
12bb45
usage: reimzul_submit.py [-h] -s SRPM -a ARCH -t TARGET -d DISTTAG [--now]
12bb45
                         [--scratch]
12bb45
12bb45
Reimzul CentOS distributed build client
12bb45
12bb45
optional arguments:
12bb45
  -h, --help            show this help message and exit
12bb45
  -s SRPM, --srpm SRPM  The src.rpm pkg already uploaded in controller node
12bb45
  -a ARCH, --arch ARCH  Defines the mock architecture to build against
12bb45
                        [example: x86_64,armhfp,aarch64,i386,ppc64le,ppc64]
12bb45
  -t TARGET, --target TARGET
12bb45
                        The target repo to build against/for, without any arch
12bb45
                        specified [example: c7.1708.u]
12bb45
  -d DISTTAG, --disttag DISTTAG
12bb45
                        Defines the mock disttag to use [example: .el7_4]
12bb45
  --now                 Will prioritize this job in front of the build queue
12bb45
  --scratch             Will just build the pkg but not prepare it in staging-
12bb45
                        tosign area
12bb45
```
12bb45
12bb45
## Upstream git repository
12bb45
12bb45
  * [reimzul](https://github.com/CentOS/reimzul)
12bb45
12bb45
12bb45
## Ansible automation roles
12bb45
12bb45
  * [ansible-role-reimzul-controller](https://github.com/CentOS/ansible-role-reimzul-controller)
12bb45
  * [ansible-role-reimzul-builder](https://github.com/CentOS/ansible-role-reimzul-builder)
12bb45
  * [ansible-role-reimzul-bstore](https://github.com/CentOS/ansible-role-reimzul-bstore)
12bb45