Преглед на файлове

On network disconnect clear the cached connections to external
nameservers

Signed-off-by: Santhosh Manohar <santhosh@docker.com>

Santhosh Manohar преди 9 години
родител
ревизия
ca06f1ed80
променени са 2 файла, в които са добавени 14 реда и са изтрити 2 реда
  1. 4 0
      libnetwork/endpoint.go
  2. 10 2
      libnetwork/resolver.go

+ 4 - 0
libnetwork/endpoint.go

@@ -547,6 +547,10 @@ func (ep *endpoint) Leave(sbox Sandbox, options ...EndpointOption) error {
 	sb.joinLeaveStart()
 	defer sb.joinLeaveEnd()
 
+	if sb.resolver != nil {
+		sb.resolver.FlushExtServers()
+	}
+
 	return ep.sbLeave(sb, false, options...)
 }
 

+ 10 - 2
libnetwork/resolver.go

@@ -28,8 +28,12 @@ type Resolver interface {
 	// NameServer() returns the IP of the DNS resolver for the
 	// containers.
 	NameServer() string
-	// To configure external name servers the resolver should use
+	// SetExtServers configures the external nameservers the resolver
+	// should use to forward queries
 	SetExtServers([]string)
+	// FlushExtServers clears the cached UDP connections to external
+	// nameservers
+	FlushExtServers()
 	// ResolverOptions returns resolv.conf options that should be set
 	ResolverOptions() []string
 }
@@ -139,11 +143,15 @@ func (r *resolver) Start() error {
 	return nil
 }
 
-func (r *resolver) Stop() {
+func (r *resolver) FlushExtServers() {
 	for i := 0; i < maxExtDNS; i++ {
 		r.extDNSList[i].extConn = nil
 		r.extDNSList[i].extOnce = sync.Once{}
 	}
+}
+
+func (r *resolver) Stop() {
+	r.FlushExtServers()
 
 	if r.server != nil {
 		r.server.Shutdown()