Repository: submariner-io/lighthouse
Pull request #432 (2021-01-12 15:47:07)

Adopt admiral API changes
 The addition of the `numRequeues` param to callback functions  and changes to broker syncer creation.


tpantelis: > Please run `go mod tidy`.

Done.
tpantelis: https://github.com/submariner-io/admiral/pull/172 also adds API changes so we can wait on this until after that is merged

Patch:
diff --git a/go.mod b/go.mod
index b857520..a74e406 100644
--- a/go.mod
+++ b/go.mod
@@ -10,7 +10,7 @@ require (
 	github.com/onsi/ginkgo v1.14.2
 	github.com/onsi/gomega v1.10.4
 	github.com/pkg/errors v0.9.1
-	github.com/submariner-io/admiral v0.8.0
+	github.com/submariner-io/admiral v0.8.1-0.20210113165042-ee5f8e389614
 	github.com/submariner-io/shipyard v0.8.0
 	k8s.io/api v0.18.4
 	k8s.io/apimachinery v0.18.4
diff --git a/go.sum b/go.sum
index 097789f..a530b9e 100644
--- a/go.sum
+++ b/go.sum
@@ -566,8 +566,8 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy
 github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
 github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/submariner-io/admiral v0.8.0 h1:M1SN2+HCBVsjv+/vOyuaE+UijuNu7vaTkw4WhTlyKk4=
-github.com/submariner-io/admiral v0.8.0/go.mod h1:z3cqLnFjYlmtJDZwnbw0wwaV2Xwlf1i4pdlQ4+D3L3A=
+github.com/submariner-io/admiral v0.8.1-0.20210113165042-ee5f8e389614 h1:cOaELyVBH/TdL6vMLxWhJIWeUYX3BQ1D7/hlHe+Vitg=
+github.com/submariner-io/admiral v0.8.1-0.20210113165042-ee5f8e389614/go.mod h1:z3cqLnFjYlmtJDZwnbw0wwaV2Xwlf1i4pdlQ4+D3L3A=
 github.com/submariner-io/shipyard v0.8.0 h1:HKvVDJ4VbEz2CFK5h7fhBCz0z421hoykp7Al7j3kE3Y=
 github.com/submariner-io/shipyard v0.8.0/go.mod h1:kPqFCYY2F9vMEzEr6YwYQ1dhwL+uXgezG0aLey5rXD0=
 github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
diff --git a/pkg/agent/controller/agent.go b/pkg/agent/controller/agent.go
index 5a2d2d8..cd1a5f1 100644
--- a/pkg/agent/controller/agent.go
+++ b/pkg/agent/controller/agent.go
@@ -28,15 +28,11 @@ import (
 	corev1 "k8s.io/api/core/v1"
 	discovery "k8s.io/api/discovery/v1beta1"
 	apierrors "k8s.io/apimachinery/pkg/api/errors"
-	"k8s.io/apimachinery/pkg/api/meta"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 	"k8s.io/apimachinery/pkg/runtime"
 	utilruntime "k8s.io/apimachinery/pkg/util/runtime"
-	"k8s.io/client-go/dynamic"
 	"k8s.io/client-go/kubernetes"
-	"k8s.io/client-go/kubernetes/scheme"
-	"k8s.io/client-go/rest"
 	"k8s.io/client-go/util/retry"
 	"k8s.io/klog"
 	mcsv1a1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1"
@@ -51,34 +47,7 @@ const (
 
 var MaxExportStatusConditions = 10
 
-func New(spec *AgentSpecification, cfg *rest.Config) (*Controller, error) {
-	kubeClientSet, err := kubernetes.NewForConfig(cfg)
-	if err != nil {
-		return nil, fmt.Errorf("Error building clientset: %s", err.Error())
-	}
-
-	syncerConf := &broker.SyncerConfig{LocalRestConfig: cfg}
-
-	restMapper, err := util.BuildRestMapper(cfg)
-	if err != nil {
-		return nil, err
-	}
-
-	localClient, err := dynamic.NewForConfig(cfg)
-	if err != nil {
-		return nil, fmt.Errorf("error creating dynamic client: %v", err)
-	}
-
-	return NewWithDetail(spec, syncerConf, restMapper, localClient, kubeClientSet, scheme.Scheme,
-		func(config *broker.SyncerConfig) (*broker.Syncer, error) {
-			return broker.NewSyncer(*config)
-		})
-}
-
-// Constructor that takes additional detail. This is intended for unit tests.
-func NewWithDetail(spec *AgentSpecification, syncerConf *broker.SyncerConfig, restMapper meta.RESTMapper, localClient dynamic.Interface,
-	kubeClientSet kubernetes.Interface, runtimeScheme *runtime.Scheme,
-	newSyncer func(*broker.SyncerConfig) (*broker.Syncer, error)) (*Controller, error) {
+func New(spec *AgentSpecification, syncerConf broker.SyncerConfig, kubeClientSet kubernetes.Interface) (*Controller, error) {
 	agentController := &Controller{
 		clusterID:        spec.ClusterID,
 		namespace:        spec.Namespace,
@@ -86,14 +55,13 @@ func NewWithDetail(spec *AgentSpecification, syncerConf *broker.SyncerConfig, re
 		kubeClientSet:    kubeClientSet,
 	}
 
-	_, gvr, err := util.ToUnstructuredResource(&mcsv1a1.ServiceExport{}, restMapper)
+	_, gvr, err := util.ToUnstructuredResource(&mcsv1a1.ServiceExport{}, syncerConf.RestMapper)
 	if err != nil {
 		return nil, err
 	}
 
-	agentController.serviceExportClient = localClient.Resource(*gvr)
+	agentController.serviceExportClient = syncerConf.LocalClient.Resource(*gvr)
 
-	syncerConf.Scheme = runtimeScheme
 	syncerConf.LocalNamespace = spec.Namespace
 	syncerConf.LocalClusterID = spec.ClusterID
 
@@ -104,7 +72,8 @@ func NewWithDetail(spec *AgentSpecification, syncerConf *broker.SyncerConfig, re
 			BrokerResourceType:   &mcsv1a1.ServiceImport{},
 		},
 	}
-	agentController.serviceImportSyncer, err = newSyncer(syncerConf)
+
+	agentController.serviceImportSyncer, err = broker.NewSyncer(syncerConf)
 	if err != nil {
 		return nil, err
 	}
@@ -125,22 +94,23 @@ func NewWithDetail(spec *AgentSpecification, syncerConf *broker.SyncerConfig, re
 			BrokerTransform: agentController.remoteEndpointSliceToLocal,
 		},
 	}
-	agentController.endpointSliceSyncer, err = newSyncer(syncerConf)
+
+	agentController.endpointSliceSyncer, err = broker.NewSyncer(syncerConf)
 	if err != nil {
 		return nil, err
 	}
 
 	agentController.serviceExportSyncer, err = syncer.NewResourceSyncer(&syncer.ResourceSyncerConfig{
 		Name:             "ServiceExport -> ServiceImport",
-		SourceClient:     localClient,
+		SourceClient:     syncerConf.LocalClient,
 		SourceNamespace:  metav1.NamespaceAll,
 		Direction:        syncer.RemoteToLocal,
-		RestMapper:       restMapper,
+		RestMapper:       syncerConf.RestMapper,
 		Federator:        agentController.serviceImportSyncer.GetLocalFederator(),
 		ResourceType:     &mcsv1a1.ServiceExport{},
 		Transform:        agentController.serviceExportToServiceImport,
 		OnSuccessfulSync: agentController.onSuccessfulServiceImportSync,
-		Scheme:           runtimeScheme,
+		Scheme:           syncerConf.Scheme,
 	})
 	if err != nil {
 		return nil, err
@@ -148,26 +118,27 @@ func NewWithDetail(spec *AgentSpecification, syncerConf *broker.SyncerConfig, re
 
 	agentController.serviceSyncer, err = syncer.NewResourceSyncer(&syncer.ResourceSyncerConfig{
 		Name:            "Service deletion",
-		SourceClient:    localClient,
+		SourceClient:    syncerConf.LocalClient,
 		SourceNamespace: metav1.NamespaceAll,
 		Direction:       syncer.RemoteToLocal,
-		RestMapper:      restMapper,
+		RestMapper:      syncerConf.RestMapper,
 		Federator:       agentController.serviceImportSyncer.GetLocalFederator(),
 		ResourceType:    &corev1.Service{},
 		Transform:       agentController.serviceToRemoteServiceImport,
-		Scheme:          runtimeScheme,
+		Scheme:          syncerConf.Scheme,
 	})
 	if err != nil {
 		return nil, err
 	}
 
-	agentController.serviceImportController, err = newServiceImportController(spec, agentController.serviceSyncer, restMapper,
-		localClient, runtimeScheme)
+	agentController.serviceImportController, err = newServiceImportController(spec, agentController.serviceSyncer,
+		syncerConf.RestMapper, syncerConf.LocalClient, syncerConf.Scheme)
 	if err != nil {
 		return nil, err
 	}
 
-	agentController.lhServiceExportController, err = newLHServiceExportController(localClient, restMapper, runtimeScheme)
+	agentController.lhServiceExportController, err = newLHServiceExportController(syncerConf.LocalClient, syncerConf.RestMapper,
+		syncerConf.Scheme)
 	if err != nil {
 		return nil, err
 	}
@@ -210,7 +181,7 @@ func (a *Controller) Start(stopCh <-chan struct{}) error {
 	return nil
 }
 
-func (a *Controller) serviceExportToServiceImport(obj runtime.Object, op syncer.Operation) (runtime.Object, bool) {
+func (a *Controller) serviceExportToServiceImport(obj runtime.Object, numRequeues int, op syncer.Operation) (runtime.Object, bool) {
 	svcExport := obj.(*mcsv1a1.ServiceExport)
 
 	if op == syncer.Delete {
@@ -342,7 +313,7 @@ func (a *Controller) onSuccessfulServiceImportSync(synced runtime.Object, op syn
 		"", "Service was successfully synced to the broker")
 }
 
-func (a *Controller) serviceToRemoteServiceImport(obj runtime.Object, op syncer.Operation) (runtime.Object, bool) {
+func (a *Controller) serviceToRemoteServiceImport(obj runtime.Object, numRequeues int, op syncer.Operation) (runtime.Object, bool) {
 	if op != syncer.Delete {
 		// Ignore create/update
 		return nil, false
@@ -513,14 +484,14 @@ func getGlobalIpFromService(service *corev1.Service) string {
 	return ""
 }
 
-func (a *Controller) remoteEndpointSliceToLocal(obj runtime.Object, op syncer.Operation) (runtime.Object, bool) {
+func (a *Controller) remoteEndpointSliceToLocal(obj runtime.Object, numRequeues int, op syncer.Operation) (runtime.Object, bool) {
 	endpointSlice := obj.(*discovery.EndpointSlice)
 	endpointSlice.Namespace = endpointSlice.GetObjectMeta().GetLabels()[lhconstants.LabelSourceNamespace]
 
 	return endpointSlice, false
 }
 
-func (a *Controller) filterLocalEndpointSlices(obj runtime.Object, op syncer.Operation) (runtime.Object, bool) {
+func (a *Controller) filterLocalEndpointSlices(obj runtime.Object, numRequeues int, op syncer.Operation) (runtime.Object, bool) {
 	endpointSlice := obj.(*discovery.EndpointSlice)
 	labels := endpointSlice.GetObjectMeta().GetLabels()
 
diff --git a/pkg/agent/controller/endpoint.go b/pkg/agent/controller/endpoint.go
index 9c33370..295bd76 100644
--- a/pkg/agent/controller/endpoint.go
+++ b/pkg/agent/controller/endpoint.go
@@ -74,7 +74,7 @@ func (e *EndpointController) stop() {
 	close(e.stopCh)
 }
 
-func (e *EndpointController) endpointsToEndpointSlice(obj runtime.Object, op syncer.Operation) (runtime.Object, bool) {
+func (e *EndpointController) endpointsToEndpointSlice(obj runtime.Object, numRequeues int, op syncer.Operation) (runtime.Object, bool) {
 	endPoints := obj.(*corev1.Endpoints)
 	endpointSliceName := endPoints.Name + "-" + e.clusterID
 
diff --git a/pkg/agent/controller/lhserviceexport.go b/pkg/agent/controller/lhserviceexport.go
index ba91608..137e0e1 100644
--- a/pkg/agent/controller/lhserviceexport.go
+++ b/pkg/agent/controller/lhserviceexport.go
@@ -64,7 +64,7 @@ func (c *LHServiceExportController) start(stopCh <-chan struct{}) error {
 	return nil
 }
 
-func (c *LHServiceExportController) LHtoMCSServiceExport(obj runtime.Object, op syncer.Operation) (runtime.Object, bool) {
+func (c *LHServiceExportController) LHtoMCSServiceExport(obj runtime.Object, numRequeues int, op syncer.Operation) (runtime.Object, bool) {
 	if op != syncer.Create {
 		return nil, false
 	}
diff --git a/pkg/agent/controller/serviceimport.go b/pkg/agent/controller/serviceimport.go
index 2cacb41..9a973af 100644
--- a/pkg/agent/controller/serviceimport.go
+++ b/pkg/agent/controller/serviceimport.go
@@ -135,7 +135,8 @@ func (c *ServiceImportController) serviceImportDeleted(serviceImport *mcsv1a1.Se
 	return false
 }
 
-func (c *ServiceImportController) serviceImportToEndpointController(obj runtime.Object, op syncer.Operation) (runtime.Object, bool) {
+func (c *ServiceImportController) serviceImportToEndpointController(obj runtime.Object, numRequeues int,
+	op syncer.Operation) (runtime.Object, bool) {
 	serviceImport := obj.(*mcsv1a1.ServiceImport)
 	key, _ := cache.MetaNamespaceKeyFunc(serviceImport)
 	if op == syncer.Create || op == syncer.Update {
diff --git a/pkg/agent/main.go b/pkg/agent/main.go
index 59d91ae..901d837 100644
--- a/pkg/agent/main.go
+++ b/pkg/agent/main.go
@@ -19,7 +19,11 @@ import (
 	"flag"
 
 	"github.com/kelseyhightower/envconfig"
+	"github.com/submariner-io/admiral/pkg/syncer/broker"
+	"github.com/submariner-io/admiral/pkg/util"
 	"github.com/submariner-io/lighthouse/pkg/agent/controller"
+	"k8s.io/client-go/dynamic"
+	"k8s.io/client-go/kubernetes"
 	"k8s.io/client-go/kubernetes/scheme"
 
 	lighthousev2a1 "github.com/submariner-io/lighthouse/pkg/apis/lighthouse.submariner.io/v2alpha1"
@@ -63,11 +67,31 @@ func main() {
 		klog.Fatalf("Error building kubeconfig: %s", err.Error())
 	}
 
+	kubeClientSet, err := kubernetes.NewForConfig(cfg)
+	if err != nil {
+		klog.Fatalf("Error building clientset: %s", err.Error())
+	}
+
+	restMapper, err := util.BuildRestMapper(cfg)
+	if err != nil {
+		klog.Fatal(err.Error())
+	}
+
+	localClient, err := dynamic.NewForConfig(cfg)
+	if err != nil {
+		klog.Fatalf("error creating dynamic client: %v", err)
+	}
+
 	klog.Infof("Starting submariner-lighthouse-agent %v", agentSpec)
 
 	// set up signals so we handle the first shutdown signal gracefully
 	stopCh := signals.SetupSignalHandler()
-	lightHouseAgent, err := controller.New(&agentSpec, cfg)
+	lightHouseAgent, err := controller.New(&agentSpec, broker.SyncerConfig{
+		LocalRestConfig: cfg,
+		LocalClient:     localClient,
+		RestMapper:      restMapper,
+		Scheme:          scheme.Scheme,
+	}, kubeClientSet)
 	if err != nil {
 		klog.Fatalf("Failed to create lighthouse agent: %v", err)
 	}


Test patch:
diff --git a/pkg/agent/controller/agent_test.go b/pkg/agent/controller/agent_test.go
index ebeadaa..321352f 100644
--- a/pkg/agent/controller/agent_test.go
+++ b/pkg/agent/controller/agent_test.go
@@ -34,7 +34,6 @@ import (
 	corev1 "k8s.io/api/core/v1"
 	discovery "k8s.io/api/discovery/v1beta1"
 	apierrors "k8s.io/apimachinery/pkg/api/errors"
-	"k8s.io/apimachinery/pkg/api/meta"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/runtime"
 	"k8s.io/apimachinery/pkg/runtime/schema"
@@ -358,15 +357,13 @@ type cluster struct {
 type testDriver struct {
 	cluster1                  cluster
 	cluster2                  cluster
-	brokerDynClient           dynamic.Interface
 	brokerServiceImportClient *fake.DynamicResourceClient
 	brokerEndpointSliceClient *fake.DynamicResourceClient
 	service                   *corev1.Service
 	serviceExport             *mcsv1a1.ServiceExport
 	endpoints                 *corev1.Endpoints
 	stopCh                    chan struct{}
-	restMapper                meta.RESTMapper
-	syncerScheme              *runtime.Scheme
+	syncerConfig              *broker.SyncerConfig
 }
 
 func newTestDiver() *testDriver {
@@ -401,11 +398,14 @@ func newTestDiver() *testDriver {
 				Selector:  map[string]string{"app": "test"},
 			},
 		},
-		restMapper: test.GetRESTMapperFor(&mcsv1a1.ServiceExport{}, &mcsv1a1.ServiceImport{},
-			&corev1.Service{}, &corev1.Endpoints{}, &discovery.EndpointSlice{}, &lighthousev2a1.ServiceExport{}),
-		brokerDynClient: fake.NewDynamicClient(syncerScheme),
-		syncerScheme:    syncerScheme,
-		stopCh:          make(chan struct{}),
+		syncerConfig: &broker.SyncerConfig{
+			BrokerNamespace: test.RemoteNamespace,
+			RestMapper: test.GetRESTMapperFor(&mcsv1a1.ServiceExport{}, &mcsv1a1.ServiceImport{},
+				&corev1.Service{}, &corev1.Endpoints{}, &discovery.EndpointSlice{}, &lighthousev2a1.ServiceExport{}),
+			BrokerClient: fake.NewDynamicClient(syncerScheme),
+			Scheme:       syncerScheme,
+		},
+		stopCh: make(chan struct{}),
 	}
 
 	t.serviceExport = &mcsv1a1.ServiceExport{
@@ -449,41 +449,37 @@ func newTestDiver() *testDriver {
 		},
 	}
 
-	t.brokerServiceImportClient = t.brokerDynClient.Resource(*test.GetGroupVersionResourceFor(t.restMapper,
+	t.brokerServiceImportClient = t.syncerConfig.BrokerClient.Resource(*test.GetGroupVersionResourceFor(t.syncerConfig.RestMapper,
 		&mcsv1a1.ServiceImport{})).Namespace(test.RemoteNamespace).(*fake.DynamicResourceClient)
 
-	t.brokerEndpointSliceClient = t.brokerDynClient.Resource(*test.GetGroupVersionResourceFor(t.restMapper,
+	t.brokerEndpointSliceClient = t.syncerConfig.BrokerClient.Resource(*test.GetGroupVersionResourceFor(t.syncerConfig.RestMapper,
 		&discovery.EndpointSlice{})).Namespace(test.RemoteNamespace).(*fake.DynamicResourceClient)
 
-	t.cluster1.init(t.restMapper, syncerScheme)
-	t.cluster2.init(t.restMapper, syncerScheme)
+	t.cluster1.init(*t.syncerConfig)
+	t.cluster2.init(*t.syncerConfig)
 
 	return t
 }
 
 func (t *testDriver) justBeforeEach() {
-	syncerConfig := &broker.SyncerConfig{
-		BrokerNamespace: test.RemoteNamespace,
-	}
-
-	t.cluster1.start(t, syncerConfig, t.syncerScheme)
-	t.cluster2.start(t, syncerConfig, t.syncerScheme)
+	t.cluster1.start(t, *t.syncerConfig)
+	t.cluster2.start(t, *t.syncerConfig)
 }
 
 func (t *testDriver) afterEach() {
 	close(t.stopCh)
 }
 
-func (c *cluster) init(restMapper meta.RESTMapper, syncerScheme *runtime.Scheme) {
-	c.localDynClient = fake.NewDynamicClient(syncerScheme)
+func (c *cluster) init(syncerConfig broker.SyncerConfig) {
+	c.localDynClient = fake.NewDynamicClient(syncerConfig.Scheme)
 
-	c.localServiceExportClient = c.localDynClient.Resource(*test.GetGroupVersionResourceFor(restMapper,
+	c.localServiceExportClient = c.localDynClient.Resource(*test.GetGroupVersionResourceFor(syncerConfig.RestMapper,
 		&mcsv1a1.ServiceExport{})).Namespace(serviceNamespace).(*fake.DynamicResourceClient)
 
-	c.localServiceImportClient = c.localDynClient.Resource(*test.GetGroupVersionResourceFor(restMapper,
+	c.localServiceImportClient = c.localDynClient.Resource(*test.GetGroupVersionResourceFor(syncerConfig.RestMapper,
 		&mcsv1a1.ServiceImport{})).Namespace(test.LocalNamespace).(*fake.DynamicResourceClient)
 
-	c.localEndpointSliceClient = c.localDynClient.Resource(*test.GetGroupVersionResourceFor(restMapper,
+	c.localEndpointSliceClient = c.localDynClient.Resource(*test.GetGroupVersionResourceFor(syncerConfig.RestMapper,
 		&discovery.EndpointSlice{})).Namespace(serviceNamespace)
 
 	fakeCS := fakeKubeClient.NewSimpleClientset()
@@ -493,11 +489,9 @@ func (c *cluster) init(restMapper meta.RESTMapper, syncerScheme *runtime.Scheme)
 	fake.AddDeleteCollectionReactor(&fakeCS.Fake, "EndpointSlice")
 }
 
-func (c *cluster) start(t *testDriver, syncerConfig *broker.SyncerConfig, syncerScheme *runtime.Scheme) {
-	agentController, err := controller.NewWithDetail(&c.agentSpec, syncerConfig, t.restMapper, c.localDynClient, c.localKubeClient,
-		syncerScheme, func(config *broker.SyncerConfig) (*broker.Syncer, error) {
-			return broker.NewSyncerWithDetail(config, c.localDynClient, t.brokerDynClient, t.restMapper)
-		})
+func (c *cluster) start(t *testDriver, syncerConfig broker.SyncerConfig) {
+	syncerConfig.LocalClient = c.localDynClient
+	agentController, err := controller.New(&c.agentSpec, syncerConfig, c.localKubeClient)
 
 	Expect(err).To(Succeed())
 	Expect(agentController.Start(t.stopCh)).To(Succeed())
@@ -832,8 +826,8 @@ func (t *testDriver) awaitNotServiceExportStatus(notCond *mcsv1a1.ServiceExportC
 }
 
 func (t *testDriver) awaitServiceExported(serviceIP string, statusIndex int) int {
-	t.awaitBrokerServiceImport(mcsv1a1.ClusterSetIP, serviceIP)
 	t.cluster1.awaitServiceImport(t.service, mcsv1a1.ClusterSetIP, serviceIP)
+	t.awaitBrokerServiceImport(mcsv1a1.ClusterSetIP, serviceIP)
 	t.cluster2.awaitServiceImport(t.service, mcsv1a1.ClusterSetIP, serviceIP)
 
 	t.awaitServiceExportStatus(statusIndex, newServiceExportCondition(mcsv1a1.ServiceExportValid,
diff --git a/pkg/agent/controller/lhserviceexport_test.go b/pkg/agent/controller/lhserviceexport_test.go
index f915f21..60e926e 100644
--- a/pkg/agent/controller/lhserviceexport_test.go
+++ b/pkg/agent/controller/lhserviceexport_test.go
@@ -31,7 +31,7 @@ var _ = Describe("ServiceExport migration", func() {
 
 	BeforeEach(func() {
 		t = newTestDiver()
-		lhServiceExportClient = t.cluster1.localDynClient.Resource(*test.GetGroupVersionResourceFor(t.restMapper,
+		lhServiceExportClient = t.cluster1.localDynClient.Resource(*test.GetGroupVersionResourceFor(t.syncerConfig.RestMapper,
 			&lighthousev2a1.ServiceExport{})).Namespace(serviceNamespace)
 	})