Commit Graph

12 Commits

Author SHA1 Message Date
Derek McGowan 075cbfd9c6 Fix file descriptor leaks
Ensures network connections and file are closed when done writing.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
2016-07-01 16:29:51 -07:00
Santhosh Manohar 7bc9320799 Fix out of bound slice access in Delete()
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-03-06 10:03:03 -08:00
Tim Hockin f0cf480fd4 Extract hostname from (hostname.domainname)
This approach allows the user to provide a FQDN as hostname if that is what
they want in their container, or to provide distinct host and domain parts.  In
both cases we will correctly extract the first token for /etc/hosts.

Signed-off-by: Tim Hockin <thockin@google.com>
2016-02-29 10:39:50 -08:00
Vincent Demeester 18fbf39c59 Use gofmt with -s instead of goimports
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2016-02-12 14:07:00 +01:00
Travis Thieman 017314473f Fix etchosts.Update to not target hosts with given hostname as prefix
Signed-off-by: Travis Thieman <travis.thieman@gmail.com>
2016-01-10 10:58:49 -05:00
Alexander Morozov 9536e8e13b Use simple scanner instead of regexp for etchosts.Delete
Benchmark results:
benchmark           old ns/op     new ns/op     delta
BenchmarkDelete     4315186       2245829       -47.96%

benchmark           old allocs     new allocs     delta
BenchmarkDelete     4645           10             -99.78%

benchmark           old bytes     new bytes     delta
BenchmarkDelete     1590011       4832          -99.70%

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-10-23 13:36:30 -07:00
Alexander Morozov ea0e4dd37f Add benchmark for etchosts.Delete
Also added more checks to test

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-10-23 13:36:30 -07:00
Jana Radhakrishnan c64fb3fcc4 Synchronize /etc/hosts updates at file level
Introduced a path level lock to synchronize updates
to /etc/hosts writes. A path level cache is maintained
to only synchronize only at the file level.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-10-21 07:45:29 -07:00
David Calavera 3afcd65d6e Move test specific functions to a testutils package.
This way we won't vendor test related functions in docker anymore.
It also moves netns related functions to a new ns package to be able to
call the ns init function in tests. I think this also helps with the
overall package isolation.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-09-07 13:33:28 -04:00
Jana Radhakrishnan 6f65b9b17d Do not update /etc/hosts for empty endpoints
There is no need to update the /etc/hosts files
of containers for endpoints which are created/deleted
in a network whose interface list is empty

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-06-24 12:09:44 -07:00
Jana Radhakrishnan d59cc6962e Add/Delete etc hosts record support
Currently the etchosts package only provides helpers
to completely build an /etc/hosts file from scratch
or update a single hostname's IP address to a different
one. This commit adds the ability to add/delete an arbitrary
number of host record entries to/from the etc hosts file

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-06-19 00:40:27 -07:00
Alessandro Boch ee72ee177d Remove pkg directory
- As recommended by Docker committers.
- Will introduce internal directory when go supports it

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-05-16 16:12:13 -07:00