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

Remove trust-ad from options line in /etc/resolv.conf #440

Merged
merged 1 commit into from
Nov 16, 2020

Conversation

philandstuff
Copy link
Contributor

Prometheus stopped working for us, with panics that look like this:

panic: runtime error: slice bounds out of range [:9] with length 8
goroutine 425 [running]:
github.com/miekg/dns.ClientConfigFromReader(0x1b914a0, 0xc051786b38, 0x0, 0xc000000000, 0xc051786b38)
        github.com/miekg/dns/clientconfig.go:94 +0x8d1
github.com/miekg/dns.ClientConfigFromFile(0x1900ba4, 0x10, 0x0, 0x0, 0x0)
        github.com/miekg/dns/clientconfig.go:29 +0xde
github.com/prometheus/prometheus/discovery/dns.lookupWithSearchPath(0xc050c8ccf0, 0x2e, 0xc0518d0001, 0x1b8f4c0, 0xc0515a1e00, 0xc051873758, 0xc00041e678, 0x7b30d0)
        github.com/prometheus/prometheus/discovery/dns/dns.go:245 +0x48
github.com/prometheus/prometheus/discovery/dns.(*Discovery).refreshOne(0xc0513c91d0, 0x1bb6140, 0xc0000d3a80, 0xc050c8ccf0, 0x2e, 0xc0519304e0, 0x26ed320, 0x164a5e0)
        github.com/prometheus/prometheus/discovery/dns/dns.go:173 +0x77
github.com/prometheus/prometheus/discovery/dns.(*Discovery).refresh.func1(0xc0513c91d0, 0x1bb6140, 0xc0000d3a80, 0xc0519304e0, 0xc0516c9250, 0xc050c8ccf0, 0x2e)
        github.com/prometheus/prometheus/discovery/dns/dns.go:154 +0x81
created by github.com/prometheus/prometheus/discovery/dns.(*Discovery).refresh
        github.com/prometheus/prometheus/discovery/dns/dns.go:153 +0x175

This looked like it was barfing on the options line in
/etc/resolv.conf, on a string of length 8.

In June, a change was made to systemd-resolved to change the options
line from options edns0 to options edns0 trust-ad. It looks like
this change is causing the panic in the miekd/dns library.

This change removes trust-ad from the options line because a) we
don't care about DNSSEC, and b) we think it's breaking things.

Note that systemd-resolved automatically determines whether it should
manage /etc/resolv.conf or not based on whether it is a symlink and
whether it includes 127.0.0.53 as a nameserver. So we think that
replacing the symlink will Do The Right Thing. We tested by manually
changing /etc/resolv.conf on a machine and rebooting it to see if it
still worked, and it did.

See https://jlk.fjfi.cvut.cz/arch/manpages/man/systemd-resolved.8#/ETC/RESOLV.CONF

Note that the selected mode of operation for this file is detected
fully automatically, depending on whether /etc/resolv.conf is a
symlink to /run/systemd/resolve/resolv.conf or lists 127.0.0.53 as
DNS server.

Co-authored-by: chrisfarms chris.farmiloe@digital.cabinet-office.gov.uk
Co-authored-by: Robert Scott robert.scott@digital.cabinet-office.gov.uk

Prometheus stopped working for us, with panics that look like this:

    panic: runtime error: slice bounds out of range [:9] with length 8
    goroutine 425 [running]:
    github.com/miekg/dns.ClientConfigFromReader(0x1b914a0, 0xc051786b38, 0x0, 0xc000000000, 0xc051786b38)
            github.com/miekg/dns/clientconfig.go:94 +0x8d1
    github.com/miekg/dns.ClientConfigFromFile(0x1900ba4, 0x10, 0x0, 0x0, 0x0)
            github.com/miekg/dns/clientconfig.go:29 +0xde
    github.com/prometheus/prometheus/discovery/dns.lookupWithSearchPath(0xc050c8ccf0, 0x2e, 0xc0518d0001, 0x1b8f4c0, 0xc0515a1e00, 0xc051873758, 0xc00041e678, 0x7b30d0)
            github.com/prometheus/prometheus/discovery/dns/dns.go:245 +0x48
    github.com/prometheus/prometheus/discovery/dns.(*Discovery).refreshOne(0xc0513c91d0, 0x1bb6140, 0xc0000d3a80, 0xc050c8ccf0, 0x2e, 0xc0519304e0, 0x26ed320, 0x164a5e0)
            github.com/prometheus/prometheus/discovery/dns/dns.go:173 +0x77
    github.com/prometheus/prometheus/discovery/dns.(*Discovery).refresh.func1(0xc0513c91d0, 0x1bb6140, 0xc0000d3a80, 0xc0519304e0, 0xc0516c9250, 0xc050c8ccf0, 0x2e)
            github.com/prometheus/prometheus/discovery/dns/dns.go:154 +0x81
    created by github.com/prometheus/prometheus/discovery/dns.(*Discovery).refresh
            github.com/prometheus/prometheus/discovery/dns/dns.go:153 +0x175

This looked like it was barfing on the `options` line in
/etc/resolv.conf, on a string of length 8.

In June, a change was made to systemd-resolved to change the options
line from `options edns0` to `options edns0 trust-ad`.  It looks like
this change is causing the panic in the miekd/dns library.

This change removes `trust-ad` from the `options` line because a) we
don't care about DNSSEC, and b) we think it's breaking things.

Note that systemd-resolved automatically determines whether it should
manage /etc/resolv.conf or not based on whether it is a symlink and
whether it includes 127.0.0.53 as a nameserver.  So we think that
replacing the symlink will Do The Right Thing.  We tested by manually
changing /etc/resolv.conf on a machine and rebooting it to see if it
still worked, and it did.

See https://jlk.fjfi.cvut.cz/arch/manpages/man/systemd-resolved.8#/ETC/RESOLV.CONF

> Note that the selected mode of operation for this file is detected
> fully automatically, depending on whether /etc/resolv.conf is a
> symlink to /run/systemd/resolve/resolv.conf or lists 127.0.0.53 as
> DNS server.

Co-authored-by: chrisfarms <chris.farmiloe@digital.cabinet-office.gov.uk>
Co-authored-by: Robert Scott <robert.scott@digital.cabinet-office.gov.uk>
@philandstuff philandstuff requested a review from a team as a code owner November 16, 2020 12:18
Copy link
Contributor

@szd55gds szd55gds left a comment

Choose a reason for hiding this comment

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

LGTM

@philandstuff philandstuff merged commit ca9461f into master Nov 16, 2020
@philandstuff philandstuff deleted the fix-resolv-conf-issues branch November 16, 2020 12:20
cbaines added a commit to alphagov/tech-ops that referenced this pull request Nov 18, 2020
This uses the same approach as taken for the Observe Prometheus [1].

The issue has been fixed in the upstream library [2] and the fix was
released in version 1.0.5, but the current Ubuntu package is built
with 1.0.4.

1: alphagov/prometheus-aws-configuration-beta#440
2: miekg/dns#642
risicle added a commit to alphagov/verify-infrastructure that referenced this pull request May 4, 2021
risicle added a commit to alphagov/verify-infrastructure that referenced this pull request May 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants