Repository: submariner-io/lighthouse
Pull request #229 (2020-07-29 15:33:31)

Rename "supercluster" to "clusterset"
The latter is the name chosen by the multi-cluster SIG.

Signed-off-by: Stephen Kitt <skitt@redhat.com>

submariner-bot: 🤖 Created branch: z_pr229/skitt/clusterset
submariner-bot: 🤖 Updated branch: z_pr229/skitt/clusterset
submariner-bot: 🤖 Updated branch: z_pr229/skitt/clusterset
submariner-bot: 🤖 Updated branch: z_pr229/skitt/clusterset
submariner-bot: 🤖 Updated branch: z_pr229/skitt/clusterset
submariner-bot: 🤖 Updated branch: z_pr229/skitt/clusterset
submariner-bot: 🤖 Updated branch: z_pr229/skitt/clusterset
submariner-bot: 🤖 Updated branch: z_pr229/skitt/clusterset
submariner-bot: 🤖 Updated branch: z_pr229/skitt/clusterset

Patch:
diff --git a/pkg/agent/controller/agent.go b/pkg/agent/controller/agent.go
index 60fce85..7d309fa 100644
--- a/pkg/agent/controller/agent.go
+++ b/pkg/agent/controller/agent.go
@@ -238,7 +238,7 @@ func (a *Controller) serviceExportToRemoteServiceImport(obj runtime.Object, op s
 		},
 	}
 
-	if svcType == lighthousev2a1.SuperclusterIP {
+	if svcType == lighthousev2a1.ClusterSetIP {
 		/* We also store the clusterIP in an annotation as an optimization to recover it in case the IPs are
 		cleared out when here's no backing Endpoint pods.
 		*/
@@ -260,7 +260,7 @@ func getServiceImportType(service *corev1.Service) (lighthousev2a1.ServiceImport
 		return lighthousev2a1.Headless, true
 	}
 
-	return lighthousev2a1.SuperclusterIP, true
+	return lighthousev2a1.ClusterSetIP, true
 }
 
 func (a *Controller) onSuccessfulServiceImportSync(synced runtime.Object, op syncer.Operation) {
@@ -330,7 +330,7 @@ func (a *Controller) endpointToRemoteServiceImport(obj runtime.Object, op syncer
 
 	ipList := getIPsFromEndpoint(ep)
 
-	if serviceImport.Spec.Type == lighthousev2a1.SuperclusterIP && len(ipList) > 0 {
+	if serviceImport.Spec.Type == lighthousev2a1.ClusterSetIP && len(ipList) > 0 {
 		/*
 			When there's no healthy pods, the IPs in the Endpoint will become empty and
 			thus we also clear the ServiceImport IPs to avoid clients sending a request
@@ -448,7 +448,7 @@ func (a *Controller) getServiceImport(svcExport *lighthousev2a1.ServiceExport) (
 }
 
 func (a *Controller) getIPsForService(service *corev1.Service, siType lighthousev2a1.ServiceImportType) []string {
-	if siType == lighthousev2a1.SuperclusterIP {
+	if siType == lighthousev2a1.ClusterSetIP {
 		mcsIp := getGlobalIpFromService(service)
 		if mcsIp == "" {
 			mcsIp = service.Spec.ClusterIP
diff --git a/pkg/apis/lighthouse.submariner.io/v2alpha1/types.go b/pkg/apis/lighthouse.submariner.io/v2alpha1/types.go
index e79d573..e1f2e4c 100644
--- a/pkg/apis/lighthouse.submariner.io/v2alpha1/types.go
+++ b/pkg/apis/lighthouse.submariner.io/v2alpha1/types.go
@@ -36,11 +36,11 @@ type ServiceExportConditionType string
 const (
 	// ServiceExportInitialized means the service export has been noticed
 	// by the controller, has passed validation, has appropriate finalizers
-	// set, and any required supercluster resources like the IP have been
+	// set, and any required clusterset resources like the IP have been
 	// reserved
 	ServiceExportInitialized ServiceExportConditionType = "Initialized"
 	// ServiceExportExported means that the service referenced by this
-	// service export has been synced to all clusters in the supercluster
+	// service export has been synced to all clusters in the clusterset
 	ServiceExportExported ServiceExportConditionType = "Exported"
 )
 
@@ -74,7 +74,7 @@ type ServiceExportList struct {
 //+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 // +genclient:noStatus
 
-// ServiceImport describes a service imported from clusters in a supercluster.
+// ServiceImport describes a service imported from clusters in a clusterset.
 type ServiceImport struct {
 	metav1.TypeMeta `json:",inline"`
 	// +optional
@@ -89,8 +89,8 @@ type ServiceImport struct {
 type ServiceImportType string
 
 const (
-	// Services are only accessible via their supercluster IP.
-	SuperclusterIP ServiceImportType = "SuperclusterIP"
+	// Services are only accessible via their clusterset IP.
+	ClusterSetIP ServiceImportType = "ClusterSetIP"
 	// Headless services allow backend pods to be addressed directly.
 	Headless ServiceImportType = "Headless"
 )
diff --git a/scripts/deploy b/scripts/deploy
index e438506..7b36e79 100755
--- a/scripts/deploy
+++ b/scripts/deploy
@@ -12,7 +12,7 @@ source ${SCRIPTS_DIR}/lib/version
 
 function update_coredns_configmap() {
     kubectl get cm -n kube-system coredns -o yaml > /tmp/coremap-${cluster}.yaml
-    if !(grep -q supercluster /tmp/coremap-${cluster}.yaml); then
+    if !(grep -q clusterset /tmp/coremap-${cluster}.yaml); then
         CLUSTER_IP=`kubectl get svc -n submariner-operator submariner-lighthouse-coredns | tail -n 1| awk '{print $3;}'`
         sed 's/dnsip/'${CLUSTER_IP}'/g' scripts/resources/coredns-cm.yaml > /tmp/coredns-cm-${CLUSTER_IP}.yaml
         sed -i -e "/Corefile:/r /tmp/coredns-cm-${CLUSTER_IP}.yaml" /tmp/coremap-${cluster}.yaml
diff --git a/scripts/resources/coredns-cm.yaml b/scripts/resources/coredns-cm.yaml
index ac31f72..4927260 100644
--- a/scripts/resources/coredns-cm.yaml
+++ b/scripts/resources/coredns-cm.yaml
@@ -1,3 +1,6 @@
+    clusterset.local:53 {
+        forward . dnsip
+    }
     supercluster.local:53 {
         forward . dnsip
     }


Test patch:
diff --git a/pkg/agent/controller/agent_test.go b/pkg/agent/controller/agent_test.go
index 06f5034..97af2eb 100644
--- a/pkg/agent/controller/agent_test.go
+++ b/pkg/agent/controller/agent_test.go
@@ -286,7 +286,7 @@ func (t *testDriver) awaitServiceImport(client dynamic.ResourceInterface, servic
 
 	Expect(serviceImport.GetAnnotations()["origin-name"]).To(Equal(t.service.Name))
 	Expect(serviceImport.GetAnnotations()["origin-namespace"]).To(Equal(t.service.Namespace))
-	Expect(serviceImport.Spec.Type).To(Equal(lighthousev2a1.SuperclusterIP))
+	Expect(serviceImport.Spec.Type).To(Equal(lighthousev2a1.ClusterSetIP))
 
 	Expect(serviceImport.Status.Clusters).To(HaveLen(1))
 	Expect(serviceImport.Status.Clusters[0].Cluster).To(Equal(clusterID))
diff --git a/pkg/serviceimport/controller_test.go b/pkg/serviceimport/controller_test.go
index 17c378e..7fc50b0 100644
--- a/pkg/serviceimport/controller_test.go
+++ b/pkg/serviceimport/controller_test.go
@@ -129,7 +129,7 @@ func newServiceImport(namespace, name, serviceIP, clusterID string) *lighthousev
 			},
 		},
 		Spec: lighthousev2a1.ServiceImportSpec{
-			Type: lighthousev2a1.SuperclusterIP,
+			Type: lighthousev2a1.ClusterSetIP,
 		},
 		Status: lighthousev2a1.ServiceImportStatus{
 			Clusters: []lighthousev2a1.ClusterStatus{
diff --git a/plugin/lighthouse/handler_test.go b/plugin/lighthouse/handler_test.go
index 49d36fa..fbeafe9 100644
--- a/plugin/lighthouse/handler_test.go
+++ b/plugin/lighthouse/handler_test.go
@@ -86,7 +86,7 @@ func testWithoutFallback() {
 
 	When("type A DNS query for an existing service with a different namespace", func() {
 		It("should succeed and write an A record response", func() {
-			lh.serviceImports.Put(newServiceImport(namespace2, service1, clusterID, []string{serviceIP}, lighthousev2a1.SuperclusterIP))
+			lh.serviceImports.Put(newServiceImport(namespace2, service1, clusterID, []string{serviceIP}, lighthousev2a1.ClusterSetIP))
 			executeTestCase(lh, rec, test.Case{
 				Qname: service1 + "." + namespace2 + ".svc.cluster.local.",
 				Qtype: dns.TypeA,
@@ -253,7 +253,7 @@ func testClusterStatus() {
 			serviceImports: setupServiceImportMap(),
 			clusterStatus:  mockCs,
 		}
-		lh.serviceImports.Put(newServiceImport(namespace1, service1, clusterID2, []string{serviceIP}, lighthousev2a1.SuperclusterIP))
+		lh.serviceImports.Put(newServiceImport(namespace1, service1, clusterID2, []string{serviceIP}, lighthousev2a1.ClusterSetIP))
 
 		rec = dnstest.NewRecorder(&test.ResponseWriter{})
 	})
@@ -273,7 +273,7 @@ func testClusterStatus() {
 
 	When("service is in two connected clusters and one has no IP", func() {
 		JustBeforeEach(func() {
-			lh.serviceImports.Put(newServiceImport(namespace1, service1, clusterID, []string{}, lighthousev2a1.SuperclusterIP))
+			lh.serviceImports.Put(newServiceImport(namespace1, service1, clusterID, []string{}, lighthousev2a1.ClusterSetIP))
 		})
 		It("should succeed and write an A record response with the available IP", func() {
 			executeTestCase(lh, rec, test.Case{
@@ -436,7 +436,7 @@ func executeTestCase(lh *Lighthouse, rec *dnstest.Recorder, tc test.Case) {
 
 func setupServiceImportMap() *serviceimport.Map {
 	siMap := serviceimport.NewMap()
-	siMap.Put(newServiceImport(namespace1, service1, clusterID, []string{serviceIP}, lighthousev2a1.SuperclusterIP))
+	siMap.Put(newServiceImport(namespace1, service1, clusterID, []string{serviceIP}, lighthousev2a1.ClusterSetIP))
 
 	return siMap
 }
diff --git a/test/e2e/discovery/service_discovery.go b/test/e2e/discovery/service_discovery.go
index 709fcfe..fd9a27d 100644
--- a/test/e2e/discovery/service_discovery.go
+++ b/test/e2e/discovery/service_discovery.go
@@ -13,9 +13,13 @@ import (
 
 const (
 	submarinerIpamGlobalIp = "submariner.io/globalIp"
+	clustersetDomain       = "clusterset.local"
 	superclusterDomain     = "supercluster.local"
 )
 
+// Both domains need to be checked, until the operator is updated to use clusterset
+var checkedDomains = []string{clustersetDomain, superclusterDomain}
+
 var _ = Describe("[discovery] Test Service Discovery Across Clusters", func() {
 	f := lhframework.NewFramework("discovery")
 
@@ -64,14 +68,14 @@ func RunServiceDiscoveryTest(f *lhframework.Framework) {
 		f.AwaitServiceImportIP(framework.ClusterA, nginxServiceClusterB)
 	}
 
-	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, superclusterDomain, true)
+	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, checkedDomains, true)
 
 	f.DeleteServiceExport(framework.ClusterB, nginxServiceClusterB.Name, nginxServiceClusterB.Namespace)
 	f.AwaitServiceImportDelete(framework.ClusterA, nginxServiceClusterB.Name, nginxServiceClusterB.Namespace)
 
 	f.DeleteService(framework.ClusterB, nginxServiceClusterB.Name)
 
-	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, superclusterDomain, false)
+	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, checkedDomains, false)
 }
 
 func RunServiceDiscoveryLocalTest(f *lhframework.Framework) {
@@ -102,7 +106,7 @@ func RunServiceDiscoveryLocalTest(f *lhframework.Framework) {
 	netshootPodList := f.NewNetShootDeployment(framework.ClusterA)
 	clusterADomain := getClusterDomain(f.Framework, framework.ClusterA, netshootPodList)
 
-	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterA, netshootPodList, clusterADomain, true)
+	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterA, netshootPodList, []string{clusterADomain}, true)
 
 	f.DeleteService(framework.ClusterA, nginxServiceClusterA.Name)
 
@@ -111,14 +115,14 @@ func RunServiceDiscoveryLocalTest(f *lhframework.Framework) {
 		f.AwaitServiceImportIP(framework.ClusterA, nginxServiceClusterB)
 	}
 
-	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, superclusterDomain, true)
+	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, checkedDomains, true)
 
 	f.DeleteServiceExport(framework.ClusterB, nginxServiceClusterB.Name, nginxServiceClusterB.Namespace)
 	f.AwaitServiceImportDelete(framework.ClusterA, nginxServiceClusterB.Name, nginxServiceClusterB.Namespace)
 
 	f.DeleteService(framework.ClusterB, nginxServiceClusterB.Name)
 
-	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, superclusterDomain, false)
+	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, checkedDomains, false)
 }
 
 func RunServiceExportTest(f *lhframework.Framework) {
@@ -145,16 +149,16 @@ func RunServiceExportTest(f *lhframework.Framework) {
 		f.AwaitServiceImportIP(framework.ClusterA, nginxServiceClusterB)
 	}
 
-	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, superclusterDomain, true)
+	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, checkedDomains, true)
 
 	f.DeleteServiceExport(framework.ClusterB, nginxServiceClusterB.Name, nginxServiceClusterB.Namespace)
 	f.AwaitServiceImportDelete(framework.ClusterA, nginxServiceClusterB.Name, nginxServiceClusterB.Namespace)
 
-	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, superclusterDomain, false)
+	verifyServiceIpWithDig(f.Framework, framework.ClusterA, nginxServiceClusterB, netshootPodList, checkedDomains, false)
 }
 
 func verifyServiceIpWithDig(f *framework.Framework, cluster framework.ClusterIndex, service *corev1.Service, targetPod *corev1.PodList,
-	domain string, shouldContain bool) {
+	domains []string, shouldContain bool) {
 	var serviceIP string
 	var ok bool
 
@@ -162,7 +166,11 @@ func verifyServiceIpWithDig(f *framework.Framework, cluster framework.ClusterInd
 		serviceIP = service.Spec.ClusterIP
 	}
 
-	cmd := []string{"dig", service.Name + "." + f.Namespace + ".svc." + domain, "+short"}
+	cmd := []string{"dig", "+short"}
+	for i := range domains {
+		cmd = append(cmd, service.Name+"."+f.Namespace+".svc."+domains[i])
+	}
+
 	op := "is"
 	if !shouldContain {
 		op += " not"