Blame

8afb12 Samuli Seppänen 2025-03-19 09:30:34 1
# Introduction 
2
3
OpenVPN project uses [Buildbot](https://buildbot.net) to help increase code quality. Buildbot is a Python application that can work in either *master* or *worker* mode. The *buildmaster* is the core server which accepts connections from *workers* and tells them what they should do. Typically the clients fetch latest sources and reports any build problems to buildbot which in turn informs developers via email. In software engineering this is called [http://en.wikipedia.org/wiki/Continuous_integration Continous integration] and helps prevent build problems go unnoticed for extended time periods. The clients (workers) can and should run on a variety of hardware / OS platforms. For the server (buildmaster) the OS choice is largely irrelevant. Buildbot is described in more detail in the [Buildbot manual](https://docs.buildbot.net/current/manual/index.html).
4
5
As the number of workers can easily get out of hand, the OpenVPN project can make use of *your* help. If you're interested in donating a buildslave please contact the buildmaster admins:
6
7
* Gert (cron2 on IRC)
8
* Samuli (mattock on IRC)
9
10
**NOTE:** The workers need root access to be able to connect to the t_client.sh test servers using OpenVPN. Moreover, anyone who controls the buildmaster can do whatever he wants on the workers by simply modifying the build procedure. For this reason you should only run workers on expendable virtual machines or containers. That said, you can grant limited *sudo* privileges to a normal user to run buildbot as a normal user: see section "Running builtdot as non-root user" for details.
11
12
# OpenVPN projects being built by Buildbot
13
14
Currently buildbot builds the following projects:
15
16
* openvpn
17
* openvpn3
18
* openvpn3-linux
19
* ovpn-dco
20
21
You can decide which ones you want your buildbot worker to build.
22
23
# List of existing workers
24
25
Here's a comprehensive list of workers already running (as of June 2022):
26
27
* debian-10
28
* debian-11
29
* debian-unstable
30
* arch
31
* fedora-34
32
* opensuse-leap-15
33
* ubuntu-1804
34
* ubuntu-2004
35
* ubuntu-2110
36
* cron2-fbsd74
37
* cron2-fbsd11
38
* cron2-fbsd12
39
* cron2-fbsd13
40
* cron2-nbsd81
41
* cron2-obsd68
42
* cron2-oi2019
43
44
# Creating a VM for a worker
45
46
A Linux VM will probably need about 1024MB of memory.The VM should have at least 8GB of diskspace, but adding a bit more helps avoid problems later on.
47
48
# Ensure that manual building works correctly
49
50
The first step is to ensure you can build all the projects you wish to build. If manually building does not work, it cannot work in buildbot, either. Please follow the instructions for each codebase on how to build.
51
52
# Setting up the VPN connection
53
54
Our buildmaster is accessible only via the community VPN. Please ask *mattock* on IRC for VPN config for your worker. You will get the config in Signal or in an GnuPG-encrypted email. The community VPN server pushes DNS servers as well, so you may want to process those if you want to use DNS names instead of IP addresses.
55
56
## Testing OpenVPN connectivity
57
58
A simple ping test should be enough to verify that your worker can reach buildmaster:
59
60
```
61
$ ping buildbot-host.openvpn.in
62
$ ping 10.18.0.59
63
```
64
65
If both work, it means your VPN client is properly configured. If pinging by name fails, but by IP works, then your VPN client is not processing DNS settings pushed by the OpenVPN server properly. But you can still point your worker to the IP, so it is not a blocker.
66
67
# Setting up a worker
68
69
## Simplistic setup
70
71
Note that Buildbot no longer supports Python 2.x, so ensure that your to-be worker has a working Python 3 installation.
72
73
A simplistic procedure for Ubuntu 20.04 is described below. As t_client tests need root-level privileges anyways, here we show how to run a worker as root:
74
75
```
76
$ sudo -i
77
$ apt-get install python3-pip
78
$ pip3 install buildbot-worker
79
$ mkdir /root/buildbot
80
$ buildbot-worker create-worker /root/buildbot buildbot-host.openvpn.in:9989 worker-name worker-password
81
```
82
83
You can get the worker name and password from *mattock*. Finally fill in the hostinfo files as described [here](https://docs.buildbot.net/current/manual/installation/worker.html).
84
85
Now you can launch the buildbot worker:
86
87
```
88
$ buildbot-worker start /root/buildbot
89
```
90
91
Check */root/buildbot/twistd.log* to see if the worker was able to successfully connect to the master. Typically the error you see is an authentication issue:
92
93
```
94
2022-06-29 11:46:44+0000 [Broker,client] unauthorized login; check worker name and password
95
```
96
97
This can mean three things:
98
* Your worker name is wrong
99
* Your worker password is wrong
100
* You worker has not yet been added to the buildmaster
101
102
If advanced topics and troubleshooting help please refer to the official Buildbot documentation:
103
104
* https://docs.buildbot.net/current/manual/installation/worker.html
105
* https://docs.buildbot.net/current/manual/installation/installation.html
106
107
## Running buildbot as non-root user
108
109
**NOTE:** these instructions have not been tested with the current (3.x) version of Buildbot, but probably still work.
110
111
Running buildbot as a root user is easiest, but you can tighten down the setup by giving a normal user limited super-user privileges.
112
113
* Create the user, e.g. *buildbot*
114
* Create the buildslave instance ("Setting up a new buildslave instance") as that user, to a user-editable location (e.g. */home/buildbot/openvpn*)
115
* Uncomment the *RUN_SUDO=sudo* line in *t_client.rc*
116
* Create a sudoers snippet in */etc/sudoers.d* with the command *visudo -f /etc/sudoers.d/buildbot*
117
118
The buildbot user needs to run two commands as *root*: 'kill' and the 'openvpn' executable inside the various directories of the buildslave project. An example visudo line would be:
119
120
```
121
buildbot ALL=(root) NOPASSWD: /usr/bin/kill,/home/buildbot/<build_slave_dir>/*/build/src/openvpn/openvpn,/home/buildbot/<build_slave_dir>/*/build/tests/unit_tests/openvpn/networking_testdriver
122
```
123
124
## Configuring a worker for connectivity tests
125
126
OpenVPN project's workers run connectivity tests against several OpenVPN test servers on every commit. Due to these tests the openvpn instances launched by buildbot need to run as *root*, or you need to configure *sudo* properly as described below.
127
128
As the tests connect to remote OpenVPN servers you will need test certificates and a *t_client.rc* config file from the buildmaster admins (see above). Once you've have the files, put them to */home/buildbot*:
129
130
```
131
$ tree /home/buildbot
132
/home/buildbot
133
├── t_client.rc
134
├── test-ca.crt
135
├── test-client.crt
136
├── test-client.key
137
└── test-ta.key
138
139
0 directories, 5 files
140
```
141
142
Note that these files are separate from the community VPN certificates. Make sure that the above files
143
144
* are named exactly as shown above or buildbot won't find them and will fail
145
* are readable by root (or the non-privileged buildbot)
146
* have strict enough permissions to keep OpenVPN happy
147
* 600 for *test-client.key*
148
* 644 for other files
149
150
After the keys are installed, a few more steps are required:
151
152
* Install *fping* and *fping6*, which the tests use to test for basic connectivity
153
* Allow outbound traffic through the local firewall to
154
* OpenVPN Git repository (git://git.code.sf.net)
155
* Cmocka Git repository (git://git.cryptomilk.org)
156
* t_client test servers (listening on UDP and TCP ports 51194-51199)
157
158
Once you're finished doing all of this, contact the buildmaster admins so that they can force a build (and the associated connectivity tests) on your worker. The first build is expected to fail, because the t_client.rc you were given first is a generic one. After the first build you can fix the values in *t_client.rc* file by looking at client test logs in *<buildslave-dir/build/<buildername>/tests/t_client_<buildername>-<id>*. For example, for the Ubuntu 12.04 worker the build logs were in this directory:
159
160
* /var/lib/buildbot/slaves/openvpn/build-ubuntu-1204-i386-stable-master/build/tests/t_client-ubuntu-1204-i386-20141217-160636
161
162
The files *<n>:ifconfig_route.txt* contain ifconfig output after OpenVPN had launched in test number <n>. Check what IPv4 and IPv6 addresses the server gave back, and edit your */home/buildbot/t_client.rc* to match. Once you've fixed all the tests ask a buildmaster maintainer to trigger a new build and see if all works as expected. Rinse and repeat as necessary.
163
164
You should run as many tests as possible. If your ISP supports IPv6, a reasonable set of tests is this:
165
166
```
167
TEST_RUN_LIST="1 1a 2 2a 2b 2c 3 4 4a 5 6"
168
```
169
170
If you lack IPV6 transport support, then use
171
172
```
173
TEST_RUN_LIST="1 2 3 4 5 6"
174
```
175
176
instead.
177
178
# Accessing buildmaster webui
179
180
When connected to the VPN Buildmaster is available at http://buildbot-host.openvpn.in:8010
181
182
# Using the local Git repo on buildmaster
183
184
Buildmaster is configured to use a local Git repository on its Docker host. To push to it use an SSH URL:
185
186
```
187
git+ssh://myuser@10.18.0.59/var/lib/repos/openvpn
188
```
189
190
To pull you can use the Git protocol:
191
192
```
193
git://10.18.0.59:9418/openvpn
194
```
195
196
# Troubleshooting
197
198
## Build failures
199
200
In case your build fails, try running the same build steps manually to see what the problem is.
201
202
## Workers running out of disk or inodes
203
204
The workers consume large amount of diskspace and inodes:
205
206
```
207
$ df -m|grep -E '(^Filesystem|vda1)'
208
Filesystem 1M-blocks Used Available Use% Mounted on
209
/dev/vda1 9196 4342 4365 50% /
210
211
$ df -i|grep -E '(^Filesystem|vda1)'
212
Filesystem Inodes IUsed IFree IUse% Mounted on
213
/dev/vda1 606208 274616 331592 46% /
214
```
215
216
This happens because workers leaves obsolete build directories laying around, removing them can help free up some space and inodes:
217
218
```
219
$ rm -rf /var/lib/buildbot/slaves/openvpn/build-*
220
```
221
222
On Ubuntu it is fairly important to remove useless kernels and kernel headers periodically:
223
224
```
225
$ apt-get autoremove
226
```
227
228
## Worker not connecting to buildmaster
229
230
The worker directory (e.g. */var/lib/buildbot/slaves/openvpn*) contains a logfile, *twistd.log*, which will help you figure out what went wrong. Usually there is an authentication problem, so double-check the worker username and password, and edit *buildbot.tac* as necessary.