فهرست منبع

libnetwork: drop (*Controller).nmap

Its only remaining purpose is to elide removing the endpoint from the
service records if it was not previously added. Deleting the service
records is an idempotent operation so it is harmless to delete service
records which do not exist.

Signed-off-by: Cory Snider <csnider@mirantis.com>
Cory Snider 1 سال پیش
والد
کامیت
33cf73f699
2فایلهای تغییر یافته به همراه1 افزوده شده و 38 حذف شده
  1. 0 2
      libnetwork/controller.go
  2. 1 36
      libnetwork/store.go

+ 0 - 2
libnetwork/controller.go

@@ -88,7 +88,6 @@ type Controller struct {
 	store            *datastore.Store
 	extKeyListener   net.Listener
 	svcRecords       map[string]*svcInfo
-	nmap             map[string]*netWatch
 	serviceBindings  map[serviceKey]*service
 	ingressSandbox   *Sandbox
 	agent            *nwAgent
@@ -112,7 +111,6 @@ func New(cfgOptions ...config.Option) (*Controller, error) {
 		sandboxes:        map[string]*Sandbox{},
 		svcRecords:       make(map[string]*svcInfo),
 		serviceBindings:  make(map[serviceKey]*service),
-		nmap:             make(map[string]*netWatch),
 		agentInitDone:    make(chan struct{}),
 		networkLocker:    locker.New(),
 		DiagnosticServer: diagnostic.New(),

+ 1 - 36
libnetwork/store.go

@@ -184,10 +184,6 @@ retry:
 	return nil
 }
 
-type netWatch struct {
-	localEps map[string]struct{}
-}
-
 func (c *Controller) watchSvcRecord(ep *Endpoint) {
 	go c.processEndpointCreate(ep)
 }
@@ -202,20 +198,7 @@ func (c *Controller) processEndpointCreate(ep *Endpoint) {
 		return
 	}
 
-	networkID := n.ID()
-	endpointID := ep.ID()
-
-	// Update the svc db for the local endpoint join right away
-	// Do this before adding this ep to localEps so that we don't
-	// try to update this ep's container's svc records
 	n.updateSvcRecord(ep, true)
-	c.mu.Lock()
-	_, ok := c.nmap[networkID]
-	if !ok {
-		c.nmap[networkID] = &netWatch{localEps: make(map[string]struct{})}
-	}
-	c.nmap[networkID].localEps[endpointID] = struct{}{}
-	c.mu.Unlock()
 }
 
 func (c *Controller) processEndpointDelete(ep *Endpoint) {
@@ -224,25 +207,7 @@ func (c *Controller) processEndpointDelete(ep *Endpoint) {
 		return
 	}
 
-	networkID := n.ID()
-	endpointID := ep.ID()
-
-	c.mu.Lock()
-	if nw, ok := c.nmap[networkID]; ok {
-		delete(nw.localEps, endpointID)
-		c.mu.Unlock()
-
-		// Update the svc db about local endpoint leave right away
-		// Do this after we remove this ep from localEps so that we
-		// don't try to remove this svc record from this ep's container.
-		n.updateSvcRecord(ep, false)
-
-		c.mu.Lock()
-		if len(nw.localEps) == 0 {
-			delete(c.nmap, networkID)
-		}
-	}
-	c.mu.Unlock()
+	n.updateSvcRecord(ep, false)
 }
 
 func (c *Controller) networkCleanup() {