ansible: osmo-gsm-tester main unit udhcpd server not started correctly during boot
For last days nanobts tests in osmo-gsm-tester have been failing.
After having a look for a while and testing booring a nanobts manually and checking with abisip-find, I noticed there was no output and finally realized the udhcpd server was not up. This is what I saw:
root@osmo-gsm-tester-prod:~# systemctl status udhcpd ● udhcpd.service - LSB: Start busybox udhcpd at boot time Loaded: loaded (/etc/init.d/udhcpd; generated; vendor preset: enabled) Active: active (exited) since Thu 2018-05-31 15:00:45 CEST; 2min 2s ago Docs: man:systemd-sysv-generator(8) Process: 299 ExecStart=/etc/init.d/udhcpd start (code=exited, status=0/SUCCESS)
Restarting it with
systemctl restart udhcpd worked fine and since then an IP addr was assigned to the BTS and I could see it with abisip-find.
Since I had restarted the main unit for other reasons a few hours ago, I thought that perhaps udhcpd was not being startup correctly during boot. I re-booted the main unit and checked at the status of the server: udhcpd again stated it 3was started but exited:
May 31 15:00:45 osmo-gsm-tester-prod systemd: Starting LSB: Start busybox udhcpd at boot time... May 31 15:00:45 osmo-gsm-tester-prod udhcpd: Starting very small Busybox based DHCP server: udhcpd. May 31 15:00:45 osmo-gsm-tester-prod systemd: Started LSB: Start busybox udhcpd at boot time. May 31 15:00:45 osmo-gsm-tester-prod udhcpd: udhcpd (v1.22.1) started May 31 15:00:45 osmo-gsm-tester-prod udhcpd: max_leases=235 is too big, setting to 6 May 31 15:00:45 osmo-gsm-tester-prod udhcpd: is interface enp2s0 up and configured?: Cannot assign requested address
So it seems udhcpd is started before the network is up, then exits. udhcpd in our current version actually seems to be using /etc/init.d/ still, for which systemc creates a temporal .service file in /run. So in order to wait for network to be up, I had to create a service file with required bits:
# cat /lib/systemd/system/udhcpd.service [Unit] Description=udhcpcd DHCP server After=network-online.target Wants=network-online.target [Service] ExecStart=/usr/sbin/udhcpd -f RestartSec=5 Restart=always [Install] WantedBy=multi-user.target
Then enabled it
systemctl enable udhcpd.server, then restarted the main unit and udhcpd started fine during boot process.
So, we need to add that file to ansible and install it into /lib/systemd/system/udhcpd.service. We also need to enable the service.