Commit Graph

23 Commits

Author SHA1 Message Date
Jana Radhakrishnan 967917c8b4 Fix race in os sandbox sharing
There is a race in os sandbox sharing code where two containers which
are sharing the os sandbox try to recreate the os sandbox again which
might result in destroying the os sandbox and recreating it. Since the
os sandbox sharing is happening only for default sandbox, refactored the
code to create os sandbox only once inside a `sync.Once` api so that it
happens exactly once and gets reused by other containers. Also disabled
deleting this os sandbox.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-11-01 08:15:32 -08:00
Madhu Venugopal e636d8398b set cntlr sandbox before cleaning endpoints in ungraceful restart case
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-10-30 14:40:17 -07:00
Madhu Venugopal c8a66f5e72 Fixes a case of ungraceful daemon restart + unreachable store
For ungraceful daemon restarts, libnetwork has sandbox cleanup logic to
remove any stale & dangling resources. But, if the store is down during
the daemon restart, then the cleanup logic would not be able to perform
complete cleanup. During such cases, the sandbox has been removed. With
this fix, we retain the sandbox if the store is down and the endpoint
couldnt be cleaned. When the container is later restarted in docker
daemon, we will perform a sandbox cleanup and that will complete the
cleanup round.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-10-29 17:16:52 -07:00
Alessandro Boch 7b4b56169b Some functions' logic cleanup
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-27 11:08:42 -07:00
Santhosh Manohar 3da8471681 Handling container rename in libnetwork
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2015-10-23 05:31:53 -07:00
Jana Radhakrishnan cdb82dc22d 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
Jana Radhakrishnan 96d819cb06 Make sandbox cleanup robust for ungraceful exits
When the daemon has a lot of containers and even when
the daemon tries to give 15 second to stop all containers
it is not enough. So the daemon forces a shut down at the end
of 15 seconds. And hence in a situation with a lot of
containers even gracefully bringing down the daemon will result
in a lot of containers fully not brought down.

In addition to this the daemon force killing itself can happen
in any arbitrary point in time which will result in inconsistent
checkpointed state for the sandbox. This makes the cleanup really
fail when we come back up and in many cases because of this
inability to cleanup properly on restart will result in daemon not
able to restart because we are not able to delete the default network.

This commit ensures that the sandbox state stored in the disk is
never inconsistent so that when we come back up we will always be
able to cleanup the sandbox state.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-10-19 13:30:47 -07:00
Jana Radhakrishnan 1ffe6fef02 Move sandbox resources when container restarts
Currently when container has a restart policy and gets
restarted, docker does not release networking and allocate
it back. But it presents libnetwork with a new sandbox while
all the network resources are locked in the old sandbox. This
commit attempts to move all the network resources from the old
sandbox to the new sandbox when libnetwork is presented with the
new sandbox.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-10-09 13:43:25 -07:00
Jana Radhakrishnan e41b4765bd Cleanup dangling sandboxes on boot up
Currently when docker exits ungracefully it may leave
dangling sandboxes which may hold onto precious network
resources. Added checkpoint state for sandboxes which
on boot up will be used to clean up the sandboxes and
network resources.

On bootup the remaining dangling state in the checkpoint
are read and cleaned up before accepting any new
network allocation requests.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-10-07 20:08:47 -07:00
Jana Radhakrishnan c74538c22e Merge pull request #565 from mavenugo/adb
Moved InterfaceStatistics from osl into types package
2015-10-06 16:10:37 -07:00
Jana Radhakrishnan 71e14dd52a Remove always-on watch for networks and endpoints
Always on watching of networks and endpoints can
affect scalability of the cluster beyond a few nodes.
Remove pro active watching and watch only the objects
you are interested in.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-10-06 14:15:49 -07:00
Alessandro Boch ddcfab5f81 libnetwork <-> ipam driver interaction
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-03 16:18:19 -07:00
Madhu Venugopal caab594ffb Moved InterfaceStatistics from osl into types package
Exposing osl package outside libnetwork is not neccessary and the
InterfaceStatistics anyways belong to the types package.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-09-26 10:12:20 -07:00
Jana Radhakrishnan 24f1845a18 Do not overwrite the /etc/hosts file on Join
Currently on every endpoint Join the /etc/hosts
file is getting overwritten. This blows the already
existing service records. Modify the `updateHostsFile`
function to build the hosts file only on the first
endpoint join and for subsequent joins just update
the existing /etc/hosts file with the additional
network specific service records.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-09-23 22:04:03 -07:00
Santhosh Manohar 1cd9c4dcaa Serialize the endpoint join/leave at the sandbox level
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2015-09-19 07:31:51 -07:00
Santhosh Manohar eb54ed5d42 Support for default gateway for containers
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2015-09-18 05:02:03 -07:00
Phil Estes 437dfd3a43 Correct perms for directory creation
Directories should be 0755, not 0644

Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
2015-09-17 15:19:23 -04:00
Jana Radhakrishnan a5bd12b963 Remove multiple interface in an endpoint
Currently the endpoint data model consists of multiple
interfaces per-endpoint. This seems to be an overkill
since there is no real use case for it. Removing it
to remove unnecessary complexity from the code.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-09-11 09:19:01 -07:00
Madhu Venugopal f59502e1bd Support to provide external key to sandbox
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-09-09 20:26:37 -07:00
Alessandro Boch b0dd4944f5 Add Refresh() to Sandbox
- Convinience API which detaches the sandbox from
  all endpoints, resets and reapply config options,
  setup discovery files, reattach to the endpoints.
  No change to the osl sandbox in use.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-09-01 21:48:14 -07:00
Alessandro Boch ef659c9049 Fix resolv.conf and hosts handling in sandbox
Two issues:
- container resolv.conf getting regenerated even when no dns configs are passed
- updateHosts should be skipped for host networking mode
- incorrect check on dnsOptions

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-09-01 17:22:28 -07:00
Tim Hockin 27296caeb8 Add DNS 'options' support
This is needed to expose DNS options like 'ndots' into containers.

https://github.com/docker/docker/issues/14069

Signed-off-by: Tim Hockin <thockin@google.com>
2015-08-28 09:19:33 -07:00
Alessandro Boch fd43ee1323 Introduce Sandbox entity
- Maps 1 to 1 with container's networking stack
- It holds container's specific nw options which
  before were incorrectly owned by Endpoint.
- Sandbox creation no longer coupled with Endpoint Join,
  sandbox and endpoint have now separate lifecycle.
- LeaveAll naturally replaced by Sandbox.Delete
- some pkg and file renaming in order to have clear
  mapping between structure name and entity ("sandbox")
- Revisited hosts and resolv.conf handling
- Removed from JoinInfo interface capability of setting hosts and resolv.conf paths
- Changed etchosts.Build() to first write the search domains and then the nameservers

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-08-27 11:19:02 -07:00