-
Notifications
You must be signed in to change notification settings - Fork 882
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
Fix etchosts.Update to not target hosts with given hostname as prefix #619
Conversation
f63bcf5
to
069c342
Compare
@mavenugo Could I bother you for a review here? Thanks in advance! |
@mrjana is the best person for this. |
@mrjana Could this be reviewed, please? It's (hopefully) a small fix for what is a very annoying bug if you happen to have containers named in such a way that you trigger it. |
@thieman is it just me or your test doesn't cover the issue? I cannot find any trailing spaces in the hosts you're using as examples. |
The trailing space is not necessary, the issue is that any entry in the hosts file of format
The test case I provided will fail if you back out my change to etchosts.go, so it's covering the issue as far as I can tell. Unless I'm misunderstanding you? edit: To state it another way, my change only matches the prefix if there is whitespace after the prefix or a literal period.
If you'd prefer, we could add another line like this:
|
@thieman sorry about the delay. Since /etc/hosts based SD is being replaced by DNS for 1.10, I am not too sure if this PR is relevant. But again, more than reviewing this change, it is important to make sure this doesn't cause any regression and hence it is better to get it reviewed by @mrjana @sanimej or @aboch who has dealt with related issues in the past. |
I wasn't aware that we were moving to a new approach for 1.10, that's very interesting to learn. 😄 Thanks for the update. |
LGTM |
@thieman Change in the Update function LGTM. I think the pattern in Delete function also needs to be changed.. its "\S*\t%s\n". If you use the --link container_name format without the alias then the /etc/hosts file entry will be "IP \t container_name \s container_id". And above pattern will not match. Looks like we need to match for \n or space. Change in this PR is still needed with the DNS based service discovery @mavenugo mentioned. Because for default bridge with --link we will continue to use /etc/hosts file. Thanks for addressing this issue. |
dac0cb0
to
ddb57d8
Compare
fb70cb7
to
cebc4fb
Compare
I'm taking a look into this now, though it looks like that Delete function was changed recently, so the bug may have been fixed then. http://github.com/docker/libnetwork/commit/9536e8e1 |
@sanimej That commit did indeed fix the problem, since it is now checking based on the suffix of the line rather than the prefix. I went ahead and added an additional regression test around that to codify the correct behavior in the test suite. Should be good for another review when you have time. 😄 edit: Actually, if what you said here was true...
Then I don't believe the current Delete function is handling that case at all, since it's looking for |
Starting to grok this a bit better...since Delete is working off of actual Record structs rather than plain strings of aliases, I think the delete will still work as long as the Record is well-formed since the "Hosts" in your example would be |
@sanimej Given that the Delete functionality seems fine, is this good for merge now? |
@@ -137,6 +137,103 @@ func TestUpdate(t *testing.T) { | |||
} | |||
} | |||
|
|||
// Regression test for GitHub issue #603 on Update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a brief note about the test rather than referring to the issue number here.
Can you also squash the two commits into one.
@thieman We can merge this if you can take care of the minor comments. Sorry about the delay. |
0aea452
to
df45dad
Compare
df45dad
to
0173144
Compare
Signed-off-by: Travis Thieman <travis.thieman@gmail.com>
@sanimej Updated and rebased on latest master, thanks! |
LGTM |
LGTM. |
Fix etchosts.Update to not target hosts with given hostname as prefix
Fixes issue #603.