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

Configure systemd-resolved on bionic+ images #1135

Merged
merged 1 commit into from Oct 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 12 additions & 15 deletions nodepool/files/elements/jenkins-slave/install.d/20-jenkins-slave
Expand Up @@ -7,27 +7,24 @@ set -eu
set -o pipefail

##
## Disable systemd-resolved on bionic images
## Configure systemd-resolved on bionic+ images
##
# We have glean to setup the interfaces and the resolvers
# from config-drive. We do not want systemd-resolved to
# interfere with that. It is enabled by default in Bionic,
# so we need to disable and mask it to prevent it from
# starting without any resolvers configured and breaking
# DNS resolution on the host.
# from config-drive. Ideally we'd like glean to configure
# systemd-resolved properly, but it can't do that right
# now. So, as a workaround, we implement a static config
# here with public DNS servers. This is necessary on bionic
# images because it enables systemd-resolved by default.
#
# ref: RI-514
# TODO(odyssey4me):
# Once glean is capable of configuring systemd-resolved
# properly, remove this workaround.
#
source /etc/lsb-release
if [[ "${DISTRIB_CODENAME}" != "trusty" ]] && [[ "${DISTRIB_CODENAME}" != "xenial" ]]; then
systemctl disable systemd-resolved
# Remove the systemd-resolved stub file
# symlink. glean will put a normal file
# in its place on boot.
rm -f /etc/resolv.conf
# To allow the image build to complete,
# we add a replacement file with a public
# resolver.
echo 'nameserver 8.8.8.8' > /etc/resolv.conf
sed -i 's/^#DNS=.*/DNS=8.8.8.8/' /etc/systemd/resolved.conf
sed -i 's/^#FallbackDNS=.*/FallbackDNS=8.8.4.4/' /etc/systemd/resolved.conf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer just one or the other. I think you should just set fallbackdns (you can set both servers there). Once /etc/resolv.conf is configured by glean that would be used. If you set DNS it will not get overridden.

For compatibility reasons, if this setting is not specified, the DNS servers listed in /etc/resolv.conf are used instead, if that file exists and any servers are configured in it. This setting defaults to the empty list.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fallbackdns

A space-separated list of IPv4 and IPv6 addresses to use as the fallback DNS servers. Any per-link DNS servers obtained from systemd-networkd.service(8) take precedence over this setting, as do any servers set via DNS= above or /etc/resolv.conf. This setting is hence only used if no other DNS server information is known. If this option is not given, a compiled-in list of DNS servers is used instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does make sense, except that this is a tested to work config. Once clean is updated we'll remove this whole block again. I'm skeptical about the statement that the fallbackdns has a hard-coded set which it uses if not configured, because we had jobs failing with nothing configured here. At this point I'd rather just get this in and move on.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have to define a fallback in order for it to be used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK. Perhaps it'll make sense to keep a fallback in place, even when glean is fixed. I'll do a PR on Monday and test with it. Thanks for digging into this and helping!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wfm, as you say, this can all hopefully be removed eventually

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR up to switch to fallbackdns only: #1137

fi

##
Expand Down