Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

units: start systemd-resolved in basic.target #22045

Merged
merged 1 commit into from Jan 9, 2022

Conversation

keszybz
Copy link
Member

@keszybz keszybz commented Jan 7, 2022

In the olden days systemd-resolved used dbus and it didn't make sense to start
it before dbus which is started fairly late. But we have mostly ported resolved
over to varlink. The queries from nss-resolve are done using varlink, so name
resolution can work without dbus. resolvectl still uses dbus, so e.g. 'resolvectl
query' will not work, but by starting systemd-resolved earlier we're not making this
any worse.

If systemd-resolved is started after dbus, it registers the name and everything
is fine. If it is started before dbus, it'll watch for the dbus socket and
connect later. So it should be fine to start systemd-resolved earlier. (If dbus
is stopped and restarted, unfortunately systemd-resolved does not reconnect.
This seems to be a small bug: since our daemons know how to watch for
dbus.socket, they could restart the watch if they ever lose the connection. But
this scenario shouldn't happen in normal boot, and restarting dbus is not
supported anyway.)

Moving the start earlier the following advantages:

  • name resolution becomes availabe earlier, in particular for synthesized
    hostnames even before the network is up.
  • basic.target is part of initrd.target, so systemd-resolved will get started
    in the initrd if installed. This is required for nfs-root when the server is
    specified using a name (https://bugzilla.redhat.com/show_bug.cgi?id=2037311).

In the olden days systemd-resolved used dbus and it didn't make sense to start
it before dbus which is started fairly late. But we have mostly ported resolved
over to varlink. The queries from nss-resolve are done using varlink, so name
resolution can work without dbus. resolvectl still uses dbus, so e.g. 'resolvectl
query' will not work, but by starting systemd-resolved earlier we're not making this
any worse.

If systemd-resolved is started after dbus, it registers the name and everything
is fine. If it is started before dbus, it'll watch for the dbus socket and
connect later. So it should be fine to start systemd-resolved earlier. (If dbus
is stopped and restarted, unfortunately systemd-resolved does not reconnect.
This seems to be a small bug: since our daemons know how to watch for
dbus.socket, they could restart the watch if they ever lose the connection. But
this scenario shouldn't happen in normal boot, and restarting dbus is not
supported anyway.)

Moving the start earlier the following advantages:
- name resolution becomes availabe earlier, in particular for synthesized
  hostnames even before the network is up.
- basic.target is part of initrd.target, so systemd-resolved will get started
  in the initrd if installed. This is required for nfs-root when the server is
  specified using a name (https://bugzilla.redhat.com/show_bug.cgi?id=2037311).
@github-actions github-actions bot added the units label Jan 7, 2022
@bluca bluca added the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Jan 7, 2022
@keszybz
Copy link
Member Author

keszybz commented Jan 9, 2022

Both focal-amd64 and focal-s390x fail in TEST-02-UNITTESTS, presumably with test-fstab-generator symlink fuckup.

@keszybz keszybz added ci-failure-appears-unrelated and removed good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed labels Jan 9, 2022
@keszybz keszybz merged commit 79a67f3 into systemd:main Jan 9, 2022
4 of 8 checks passed
@keszybz keszybz deleted the resolved-start-earlier branch January 9, 2022 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants