Commit Graph

29 Commits

Author SHA1 Message Date
Alessandro Boch c70cfcb150 Provide interface to categorize errors
- Package types to define the interfaces libnetwork errors
  may implement, so that caller can categorize them.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-05-20 22:29:29 -07:00
Jana Radhakrishnan a9fa764cbb Move network types to types package
This is need to decouple types from netutils which has linux
dependencies. This way the client code which needs network types
can just pull in types package which makes client code platform
agnostic.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-05-20 20:28:46 +00:00
Jana Radhakrishnan 407e41d394 Fix /etc/resolv.conf permission issue
The container's /etc/resolv.conf permission was getting setup
as 0600 while it should be 0644 for every user inside the
container to be able to read it. The tempfile that we create
initially to populate the resolvconf content is getting created
with 0600 mode. Changed it to 0644 once it is created since there
is noway to pass mode option to ioutil.Tempfile

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-05-20 05:46:30 +00:00
Jana Radhakrishnan b323d571b5 Driver api refactor
Refactored the driver api so that is aligns well with the design
of endpoint lifecycle becoming decoupled from the container lifecycle.
Introduced go interfaces to obtain address information during CreateEndpoint.
Go interfaces are also used to get data from driver during join.
This sort of deisgn hides the libnetwork specific type details from drivers.

Another adjustment is to provide a list of interfaces during CreateEndpoint. The
goal of this is many-fold:
     * To indicate to the driver that IP address has been assigned by some other
       entity (like a user wanting to use their own static IP for an endpoint/container)
       and asking the driver to honor this. Driver may reject this configuration
       and return an error but it may not try to allocate an IP address and override
       the passed one.
     * To indicate to the driver that IP address has already been allocated once
       for this endpoint by an instance of the same driver in some docker host
       in the cluster and this is merely a notification about that endpoint and the
       allocated resources.
     * In case the list of interfaces is empty the driver is required to allocate and
       assign IP addresses for this endpoint.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-05-18 22:36:00 +00:00
Madhu Venugopal 80ad544b26 Merge pull request #164 from aboch/pg
Remove pkg directory
2015-05-17 08:29:58 -07:00
Alessandro Boch f16db2c3ad 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
Madhu Venugopal e2fea0f945 Ignore the OldHash if the resolvConfPath is invalid
If resolvConfPath is unavailable and if the internally generated .hash file
is still present, then updateDNS should not consider the presence of internally
generated .hash. Rather, it must handle it as a case of using this
resolvConfPath for the first time.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-05-16 05:35:04 -07:00
Jana Radhakrishnan d96e94897e Fix DNS entry update issue
When an update is done to the container resolv.conf file
and it was inheriting host entries, then we should not
re-read the host entries when the container leaves and
re-joins the endpoint.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-05-15 21:01:53 +00:00
Jana Radhakrishnan 7f7d9abd87 Make endpoint Join and Leave multi-thread safe
- Refactored the Join/Leave code so they are synchronized across multiple go-routines
    - Added parallel test coverage to test mult-thread access to Join/Leave
    - Updated sandbox code to revert back to caller namespace when removing interfaces
    - Changed the netns path to /var/run/netns so the cleanup is simpler on machine
      reboot scenario

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-05-10 17:36:04 +00:00
Jana Radhakrishnan 9a5217b514 Copied etchosts and resolvconf packages to libnetwork.
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-05-06 22:26:58 +00:00
Madhu Venugopal 570a76384a Handled endpoint delete with active containers attached to it
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-05-06 13:04:39 -07:00
Jana Radhakrishnan 3919b126a9 Added support for network specific enable ipv6 label
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-05-06 17:43:34 +00:00
Jana Radhakrishnan c9b54861e7 - Moved label definitions to a new package
- Added a network scope well-defined label
  to enable ipv6

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-05-06 17:21:19 +00:00
Jana Radhakrishnan ff36e97f45 Properly handle Leave by
- Removing interface from the sandbox
  - Deleting Iptable rules in the bridge driver

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-05-06 00:34:38 +00:00
Alessandro Boch ec4e1da3c5 Separate ExposedPorts from PortBindings in libnetwork API
- Fix missing code in tests in 64cceb37ad1c16884d709fd49fba34e8a99d8c41

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-05-05 16:17:17 -07:00
Alessandro Boch 706c01073d CreateOptionPortMapping to store a copy of the passed bindings
- Given this will be internal data, make a defensive copy to
  protect from client inadvertently modifications.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-05-04 23:45:07 -07:00
Jana Radhakrishnan 55099e9656 - Removed sandbox override option from the driver.
- Reworked the host network mode support by introducing
  a new JoinOption.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-05-05 04:26:23 +00:00
Jana Radhakrishnan db2f7c6f28 Added support for /etc/resolv.conf
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-05-05 00:16:36 +00:00
Jana Radhakrishnan 66eb3e1cd4 - Added support for JoinInfo so that driver can override certain
container config.
- Added JoinOption processing for extra /etc/hosts record.
- Added support for updating /etc/hosts entries of other containers.
- Added sandbox support for adding a sandbox without the OS level create.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-05-05 00:09:11 +00:00
Alessandro Boch 56741e7d60 Provide API to retrieve Endpoint operational data
- from the driver

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-05-04 14:54:48 -07:00
Madhu Venugopal 95c5eb2856 Ignoring Driver failure on Leave.
After some delibration, we think it is better not to hold onto the
sandbox resources if an explicit call to Leave fails by the Driver.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-05-03 07:29:24 -07:00
Alessandro Boch da97978469 Remove redundant code in endpoint.go
- JoinOption, LeaveOption, EndpointOption are all the same thing

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-05-02 23:55:37 -07:00
Alessandro Boch da1cddc320 Bridge to handle port mapping
- libnetwork cares for list of exposed ports, driver cares
  for list of port bindings. At endpoint creation:
  - list of exposed ports will be passed as libnetwork otion
  - list of port mapping will be passed as driver option

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-05-02 23:25:01 -07:00
Alessandro Boch 781bcc94a7 Params of non-exported struct should be non-exported
- in error.go

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-05-02 17:30:20 -07:00
Madhu Venugopal 9db6a1b8e4 Join / Leave Driver API
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-05-01 13:38:26 -07:00
Madhu Venugopal cc4f27f6af Minor API modifications
* Modified NB API with self referential var-aarg for future proofing the APIs
* Modified Driver API's option parameter to be a Map of interface{}

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-05-01 10:49:25 -07:00
Alessandro Boch 0d3ad0eaee Control scope of JoinOption functions
ISSUE:
- JoinOption type takes the exported interface Endpoint as parameter.
  This does not allows libnetwork to control the setter functions
  which will be executed by processOptions(). Client can now craft
  any func (e Endpoint), pass it to Endpoint.Join() and have it executed.
  Beside the fact this allows the client to shot himself in the foot,
  there seem not to be a real need in having the JoinOption take the
  Endpoint interface as parameter.

CHANGE:
- Changing the JoinOption signature to take a pointer to the unexported
  endpoint structure. So now libnetwork is the only one that can define
  the Join() method's options setter functions via the self referenced
  JoinOption[...] functions.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-04-30 10:49:31 -07:00
Jana Radhakrishnan b8f81862d0 - Added Join option support
- Added basic /etc/hosts generation support in libnetwork

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-04-30 05:58:12 +00:00
Jana Radhakrishnan 713ff79ed5 Reorganized the libnetwork code to seperate Controller, Network and Endpoint
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-04-30 01:25:01 +00:00