I filed an MP for impish and and MR for Debian at
https://salsa.debian.org/dns-team/bind9/-/merge_requests/17 with the
missing commit and a regression autopkgtest test case.

I will start working on SRUs after I get reviews on those.

Note that there may be an issue with testing the changes using nginx in
impish, which is being addressed here: https://salsa.debian.org/dns-
team/bind9/-/merge_requests/17/diffs#146a89a78e4846ec68c44d1e006f142585418863_0_81

The reason I am mentioning nginx in particular is that this is the
package that led the reporter to file this bug against bind9. If you are
not interested in the resolution for nginx, you can skip the rest of
this comment.

The nginx package in impish has an ExecStartPre= directive in it's
systemd unit file. While testing the patch above with the provided
autopkgtest test case (without the sed command to remove the
ExecStartPre= directive) I was facing a situation where the test would
succeed in some of the runs, and fail in other runs.

The issue did not happen for focal, which does not contain the
ExecStartPre= directive in the nginx unit file. In the failing cases,
checking the systemd service status (or logs) for nginx would contain
errors on failed configuration file checks (which is what the
ExecStartPre= directives does in the impish nginx package), hindering
the service start up process:

```
Jun 18 18:37:41 test-bind9-repr-script-impish systemd[1]: Starting A high 
performance web server and a reverse proxy server...
Jun 18 18:37:41 test-bind9-repr-script-impish nginx[285]: nginx: [emerg] host 
not found in upstream "bind9test.debian.dev" in 
/etc/nginx/sites-enabled/default:4
Jun 18 18:37:41 test-bind9-repr-script-impish nginx[285]: nginx: configuration 
file /etc/nginx/nginx.conf test failed
Jun 18 18:37:41 test-bind9-repr-script-impish systemd[1]: nginx.service: 
Control process exited, code=exited, status=1/FAILURE
Jun 18 18:37:41 test-bind9-repr-script-impish systemd[1]: nginx.service: Failed 
with result 'exit-code'.
Jun 18 18:37:41 test-bind9-repr-script-impish systemd[1]: Failed to start A 
high performance web server and a reverse proxy server.
```

Sometimes, disabling the nginx service, enabling it back, and rebooting
the system was the only way I could get the issue to manifest itself
(which would still be an intermittent issue).

Here is a short reproducer for the issue I am observing. un-commenting
the Wants bit does the trick and get everything to start in the expected
order.

```
#!/bin/bash

set -xe

MAIN_UNIT=$HOME/.config/systemd/user/reproducer-main.service
DEPENDENCY_UNIT=$HOME/.config/systemd/user/reproducer-dependency.service
TMP_LOGFILE=$(tempfile)

cat << EOF > $MAIN_UNIT
[Unit]
Description=testing stuff
After=reproducer-dependency.service
# Wants=reproducer-dependency.service

[Service]
Type=forking
ExecStartPre=sh -c 'echo I should be msg 2 >> $TMP_LOGFILE'
ExecStart=sh -c 'echo I should be msg 3 >> $TMP_LOGFILE'

[Install]
WantedBy=default.target
EOF

cat << EOF > $DEPENDENCY_UNIT
[Unit]
Description=This should be triggered BEFORE everything else

[Service]
Type=forking
ExecStart=sh -c 'echo I should be msg 1 >> $TMP_LOGFILE'

[Install]
WantedBy=default.target
EOF

echo 'Starting order with the unit containing the After= directive first' >> 
$TMP_LOGFILE
systemctl --user start reproducer-main.service reproducer-dependency.service
systemctl --user stop reproducer-main.service reproducer-dependency.service
echo
echo 'Starting order with the unit containing the After= directive last' >> 
$TMP_LOGFILE
systemctl --user start reproducer-dependency.service reproducer-main.service
systemctl --user stop reproducer-dependency.service reproducer-main.service

cat $TMP_LOGFILE

rm -f $TMP_LOGFILE $MAIN_UNIT $DEPENDENCY_UNIT
```

This is the output I get from it:

```
Starting order with the unit containing the After= directive first
I should be msg 2
I should be msg 1
I should be msg 3
Starting order with the unit containing the After= directive last
I should be msg 1
I should be msg 2
I should be msg 3
```

Is this just the expected systemd behaviour (am I missing something)? I
could not find anything in the docs on how ExecStartPre= directives
relate to the Atfter= ones.

The final consequence here is that, although the proposed patch fixes
the issue, it does not address the user request on how nginx and bind9
services interact with each other.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1899902

Title:
  systemd unit service file does not wait for bind9 to be ready

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bind9/+bug/1899902/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to