瀏覽代碼

Resolver sockets not flushed on default gw change

Currently when the default gw changes because of
other network connections happening in the container
the resolver sockets are not flushed. This results
in a subsequent DNS failure for external queries

A sequence of connecting the container to an overlay
network and subsequently to a bridge network without
disconnecting from any network will result in this
behaviour. This was revealed by one of the libnetwork
IT tests.

This is now fixed as part of the commit by flushing
the external query sockets when a default gw change
is detected.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
Jana Radhakrishnan 9 年之前
父節點
當前提交
d81a91ebad
共有 2 個文件被更改,包括 8 次插入0 次删除
  1. 4 0
      libnetwork/endpoint.go
  2. 4 0
      libnetwork/resolver.go

+ 4 - 0
libnetwork/endpoint.go

@@ -477,6 +477,10 @@ func (ep *endpoint) sbJoin(sb *sandbox, options ...EndpointOption) error {
 					ep.Name(), ep.ID(), err)
 			}
 		}
+
+		if sb.resolver != nil {
+			sb.resolver.FlushExtServers()
+		}
 	}
 
 	if !sb.needDefaultGW() {

+ 4 - 0
libnetwork/resolver.go

@@ -158,6 +158,10 @@ func (r *resolver) Start() error {
 
 func (r *resolver) FlushExtServers() {
 	for i := 0; i < maxExtDNS; i++ {
+		if r.extDNSList[i].extConn != nil {
+			r.extDNSList[i].extConn.Close()
+		}
+
 		r.extDNSList[i].extConn = nil
 		r.extDNSList[i].extOnce = sync.Once{}
 	}