Revert "libnet: setupDNS: don't overwrite user-modified resolv.conf" - #51615
Conversation
|
@akerouanton is it planed to add an regression test for this? |
|
@b-reich We don't have a proper way to write regression tests for upgrades unfortunately. But yeah, we talked about that and it's not the first time we missed that capability. We'd like to add it eventually. At least, with this PR we're going back to a known-good state. |
I rolled back the code and tested the above steps, and found that it works normally. Are there any other steps that can be reproduced? |
Hi @zhangguanzhang - I'm not sure whether you're asking about verifying the revert, or reproducing the issue? But, to repro the issue (in 29.1.0, without the revert) ... it's enough to create a container on a user-defined network, modify its |
Thanks for the answer. So, if you're only using version 29.1.0 to reproduce the issue, you can use the following steps: |
The regression test kept the container's resolv.conf hash file in sync within a single run, so it passed both with and without moby#51615 and did not actually guard the regression (as @corhere pointed out on the review). Inject the out-of-sync ("stale") hash state before the sandbox restart to simulate the Engine upgrade described in moby#51614 / moby#51619 (a resolv.conf written by a newer Engine whose rebuildDNS() left the hash file stale). With moby#51615 reverted, sbRestart.extDNS is now empty because setupDNS/rebuildDNS bail out on the stale hash and never extract the upstream nameserver, so the test fails as expected; with the fix in place it passes. Signed-off-by: Ousama Ben Younes <benyounes.ousama@gmail.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- What I did
On upgrade to v29.1.0, the Engine would consider that containers'
/etc/resolv.confwere user-modified because hash files were out-of-sync with file contents written by a prior Engine version. This was caused bysb.rebuildDNS()never updating the hash file along with the file content.In #51507, we fixed that (see commit eb18b39), and we added an extra check in
sb.setupDNS()to ensure that user-modified/etc/resolv.confaren't overwritten.But, when a new Sandbox is created (as when a container is restarted),
sb.setupDNS()is called first to copy the host's/etc/resolv.confinto the sandbox, and thensb.rebuildDNS()is used to setnameserver 127.0.0.11and extract the list of upstream nameservers that should be configured on the embedded DNS server.Prior to v29.1.0,
sb.setupDNS()was called unconditionally — ensuring the/etc/resolv.confand its hash file were in sync. Then,sb.rebuildDNS()would be called and always proceed — extracting the list of upstream nameservers.With v29.1.0,
sb.setupDNS()is skipped because of the out-of-sync hash file, which causessb.rebuildDNS()to be skipped too, and the list of upstream nameservers to never be extracted.Revert the whole PR.
- How to verify it
Both
digshould work properly:- Human readable description for the release notes