소스 검색

Add all backend ip into service records if no vip

Right now if no vip is provided only when a new loadbalancer is created
we add the service records of the backend ip. But it should happen all
the time. This is to make DNS RR on service name work.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
Jana Radhakrishnan 9 년 전
부모
커밋
10fcb9dd2a
1개의 변경된 파일15개의 추가작업 그리고 15개의 파일을 삭제
  1. 15 15
      libnetwork/service_linux.go

+ 15 - 15
libnetwork/service_linux.go

@@ -60,6 +60,13 @@ func (c *controller) addServiceBinding(name, sid, nid, eid string, vip net.IP, i
 	// applications have access to DNS RR.
 	n.(*network).addSvcRecords("tasks."+name, ip, nil, false)
 
+	// Add service name to vip in DNS, if vip is valid. Otherwise resort to DNS RR
+	svcIP := vip
+	if len(svcIP) == 0 {
+		svcIP = ip
+	}
+	n.(*network).addSvcRecords(name, svcIP, nil, false)
+
 	s.Lock()
 	defer s.Unlock()
 
@@ -85,13 +92,6 @@ func (c *controller) addServiceBinding(name, sid, nid, eid string, vip net.IP, i
 		// we add a new service service in IPVS rules.
 		addService = true
 
-		// Add service name to vip in DNS, if vip is valid. Otherwise resort to DNS RR
-		svcIP := vip
-		if len(svcIP) == 0 {
-			svcIP = ip
-		}
-
-		n.(*network).addSvcRecords(name, svcIP, nil, false)
 	}
 
 	lb.backEnds[eid] = ip
@@ -124,6 +124,14 @@ func (c *controller) rmServiceBinding(name, sid, nid, eid string, vip net.IP, in
 	// Delete the special "tasks.svc_name" backend record.
 	n.(*network).deleteSvcRecords("tasks."+name, ip, nil, false)
 
+	// Make sure to remove the right IP since if vip is
+	// not valid we would have added a DNS RR record.
+	svcIP := vip
+	if len(svcIP) == 0 {
+		svcIP = ip
+	}
+	n.(*network).deleteSvcRecords(name, svcIP, nil, false)
+
 	s.Lock()
 	defer s.Unlock()
 
@@ -139,14 +147,6 @@ func (c *controller) rmServiceBinding(name, sid, nid, eid string, vip net.IP, in
 		// remove the service entry in IPVS.
 		rmService = true
 
-		// Make sure to remove the right IP since if vip is
-		// not valid we would have added a DNS RR record.
-		svcIP := vip
-		if len(svcIP) == 0 {
-			svcIP = ip
-		}
-
-		n.(*network).deleteSvcRecords(name, svcIP, nil, false)
 		delete(s.loadBalancers, nid)
 	}