net: TestUpdateResolvConf fails since https://github.com/golang/go/commit/5efbdd9d10908206d4e0351cb4724c5fefdfa2be #14437
changed the title
net: TestUpdateResolvConf fails since 5efbdd9d10908206d4e0351cb4724c5fefdfa2be
Feb 21, 2016
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 184.108.40.206\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.