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

Update resolve.conf in containers on file creation. #10713

Merged
merged 1 commit into from Mar 4, 2015
Merged

Update resolve.conf in containers on file creation. #10713

merged 1 commit into from Mar 4, 2015

Conversation

ghost
Copy link

@ghost ghost commented Feb 11, 2015

NetworkManager updates resolve.conf by replacing the current file
with an updated one. This change enables docker to listen for these
events.

I was playing around with @estesp's patch to see if changes made by NetworkManager (when disconnecting from the network or switching to wifi for example) are picked up by the containers after a restart. It turns out that the changes were not picked up because the file is replaced rather than modified.

@estesp
Copy link
Contributor

estesp commented Feb 11, 2015

This looks like a good catch. Thanks!

@LK4D4
Copy link
Contributor

LK4D4 commented Feb 11, 2015

@swagiaal Thank you! can we write test for this? I think similar test exists for writing file.

@ghost
Copy link
Author

ghost commented Feb 12, 2015

Cool! I'll work on a test then

@ghost
Copy link
Author

ghost commented Feb 17, 2015

Hey guys sorry for the delayed update but I ran into a few hurdles which I will outline here so you can give me some pointers if I have missed something.

The first issue was with writing the test. In order to test replacing resolv.conf with resolv.conf.tmp, resolv.conf must be removed but during the test resolv.conf is a bind mount and therefor must be unmounted, written, then the rest of the test can procede with replacing and checking for updates.

The other issue is to get the CREATE event one must watch the directory '/etc' and not just '/etc/resolv.conf' (I must have missed something the first time, but the test makes this clear) so I have added that to the patch.

The last thing is that, while watching /etc suffices for most cases, when /etc/resolv.conf is a bind mount watching the directory will not notify you of any changes which are made to the file. So I have kept the original watch on /etc/resolv.conf

What do you guys think ?

@jessfraz
Copy link
Contributor

@estesp wdyt?

@estesp
Copy link
Contributor

estesp commented Feb 19, 2015

Thanks for digging into this--obviously the replace/rename is a case that needed coverage and testing. Could you remove the watcher.Add() on the filename itself? After @crosbymichael and I did some local testing, that (original) watcher on the filename is useless because a REMOVE event happens, leaving it dormant after that, which is why you had to add a watcher on the directory to catch CREATE.

After that change, LGTM

@ghost
Copy link
Author

ghost commented Feb 19, 2015

@estesp hmmm... that was my first instinct as well. The issue is if I remove the file watcher, your original tests do not pass. The reason for this is that during the test run /etc/resolv.conf is a bind mount and having a watcher on /etc is not enough when /etc/resolv.conf is a bind mount. The test can be changed of course to read resolv.conf, unmount it, write the original file and continue if we choose to remove the file watcher. If we choose to keep the file watcher we would have to handling the dangling watcher situation you mentioned. WDYT?

@estesp
Copy link
Contributor

estesp commented Feb 19, 2015

@crosbymichael do we think we need to support /etc/resolv.conf being a bind-mount in normal scenarios for update? As in, the host/daemon is either a Docker container (like in test mode), or the host/daemon already has some unique setup where /etc/resolv.conf is a bind mount?

@estesp
Copy link
Contributor

estesp commented Feb 19, 2015

@swagiaal let's go ahead and fix the test condition with unmount, like you did for your test. @crosbymichael and I agreed it is a rare case, and therefore the only impact is no support for resolv conf updating when /etc/resolv.conf itself is a bind mount on the host/daemon.

NetworkManager updates resolve.conf by replacing the current file
with an updated one. This change enables docker to listen for these
events.

Signed-off-by: Sami Wagiaalla <swagiaal@redhat.com>
@ghost
Copy link
Author

ghost commented Feb 20, 2015

@estesp thanks for following up with @crosbymichael. I have made the changes you suggested: removed the file watcher, and modified the test case to unmount resollv.conf and test using a regular file.

@estesp
Copy link
Contributor

estesp commented Feb 24, 2015

@crosbymichael I think this is ready for LGTM unless we have any other thoughts here

@ghost
Copy link
Author

ghost commented Mar 2, 2015

@crosbymichael hey... have you had a chance to look at this ?

@jessfraz
Copy link
Contributor

jessfraz commented Mar 4, 2015

can we have an integration test?

@estesp
Copy link
Contributor

estesp commented Mar 4, 2015

it was added to the current integration-cli test for resolvconf watcher cases (he added "#6" to test the creation vs. modification path)

@jessfraz
Copy link
Contributor

jessfraz commented Mar 4, 2015

wow sorry, read wrong LGTM

@estesp
Copy link
Contributor

estesp commented Mar 4, 2015

LGTM

estesp added a commit that referenced this pull request Mar 4, 2015
Update resolv.conf in containers on file creation.
@estesp estesp merged commit 2380004 into moby:master Mar 4, 2015
@ghost
Copy link
Author

ghost commented Mar 4, 2015

Thanks for reviewing and merging!

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

5 participants