Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
net: TestUpdateResolvConf fails since https://github.com/golang/go/commit/5efbdd9d10908206d4e0351cb4724c5fefdfa2be #14437
The problem as far as I can tell it is TestUpdateResolvConf uses resolvConfTest to write and load a /tmp/foo/resolv.conf file like "nameserver 126.96.36.199\n". However, the actual DNS resolver code still checks /etc/resolv.conf.
The logic in forceUpdate intentionally zeros out lastChecked (which only limits os.Stat calls), but previously it left conf.mtime untouched. So the next DNS client call would call os.Stat("/etc/resolv.conf") and see it (most likely) still matches conf.mtime.
However, now that conf.mtime has been moved to conf.dnsConfig.mtime, the tryUpdate("/etc/resolv.conf") calls are noticing that /etc/resolv.conf's mtime does not match /tmp/foo/resolv.conf, and reloading the file.
The quick fix to restore the previous behavior would be changing forceUpdate to something like:
However, that feels hacky to me. I'm thinking writeAndUpdate should actually set lastChecked to far in the future to avoid it being reloaded, and then only teardown needs to zero out lastChecked.