From aeb416ac10571de0570294792a84c2d023895064 Mon Sep 17 00:00:00 2001 From: John Howard Date: Thu, 19 Dec 2024 11:53:14 -0800 Subject: [PATCH] Cleanup deadcode in multicluster controller (#54426) All of this is handled in other parts of the code now so this was dead --- pilot/pkg/bootstrap/servicecontroller.go | 3 --- .../kube/controller/multicluster.go | 18 ++---------------- .../kube/controller/multicluster_test.go | 8 ++++---- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/pilot/pkg/bootstrap/servicecontroller.go b/pilot/pkg/bootstrap/servicecontroller.go index 0b5eda25d291..9f8ecc8a1cdc 100644 --- a/pilot/pkg/bootstrap/servicecontroller.go +++ b/pilot/pkg/bootstrap/servicecontroller.go @@ -80,11 +80,8 @@ func (s *Server) initKubeRegistry(args *PilotArgs) (err error) { args.RegistryOptions.KubeOptions.MeshServiceController = s.ServiceController() // pass namespace to k8s service registry kubecontroller.NewMulticluster(args.PodName, - s.kubeClient.Kube(), - args.RegistryOptions.ClusterRegistriesNamespace, args.RegistryOptions.KubeOptions, s.serviceEntryController, - s.configController, s.istiodCertBundleWatcher, args.Revision, s.shouldStartNsController(), diff --git a/pilot/pkg/serviceregistry/kube/controller/multicluster.go b/pilot/pkg/serviceregistry/kube/controller/multicluster.go index 925c8594aae1..cc519bb4493b 100644 --- a/pilot/pkg/serviceregistry/kube/controller/multicluster.go +++ b/pilot/pkg/serviceregistry/kube/controller/multicluster.go @@ -20,7 +20,6 @@ import ( "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/kubernetes" "istio.io/api/annotation" "istio.io/istio/pilot/pkg/config/kube/crdclient" @@ -76,13 +75,9 @@ type Multicluster struct { // options to use when creating kube controllers opts Options - // client for reading remote-secrets to initialize multicluster registries - client kubernetes.Interface - s server.Instance + s server.Instance serviceEntryController *serviceentry.Controller - configController model.ConfigStoreController - XDSUpdater model.XDSUpdater clusterLocal model.ClusterLocalProvider @@ -90,19 +85,14 @@ type Multicluster struct { caBundleWatcher *keycertbundle.Watcher revision string - // secretNamespace where we get cluster-access secrets - secretNamespace string - component *multicluster.Component[*kubeController] + component *multicluster.Component[*kubeController] } // NewMulticluster initializes data structure to store multicluster information func NewMulticluster( serverID string, - kc kubernetes.Interface, - secretNamespace string, opts Options, serviceEntryController *serviceentry.Controller, - configController model.ConfigStoreController, caBundleWatcher *keycertbundle.Watcher, revision string, startNsController bool, @@ -114,14 +104,10 @@ func NewMulticluster( serverID: serverID, opts: opts, serviceEntryController: serviceEntryController, - configController: configController, startNsController: startNsController, caBundleWatcher: caBundleWatcher, revision: revision, - XDSUpdater: opts.XDSUpdater, clusterLocal: clusterLocal, - secretNamespace: secretNamespace, - client: kc, s: s, } mc.component = multicluster.BuildMultiClusterComponent(controller, func(cluster *multicluster.Cluster) *kubeController { diff --git a/pilot/pkg/serviceregistry/kube/controller/multicluster_test.go b/pilot/pkg/serviceregistry/kube/controller/multicluster_test.go index 97655b885754..33ead02e1702 100644 --- a/pilot/pkg/serviceregistry/kube/controller/multicluster_test.go +++ b/pilot/pkg/serviceregistry/kube/controller/multicluster_test.go @@ -95,12 +95,12 @@ func Test_KubeSecretController(t *testing.T) { stop := test.NewStop(t) s := server.New() mcc := initController(clientset, testSecretNameSpace, stop) - mc := NewMulticluster("pilot-abc-123", clientset.Kube(), testSecretNameSpace, Options{ + mc := NewMulticluster("pilot-abc-123", Options{ ClusterID: "cluster-1", DomainSuffix: DomainSuffix, MeshWatcher: mesh.NewFixedWatcher(&meshconfig.MeshConfig{}), MeshServiceController: mockserviceController, - }, nil, nil, nil, "default", false, nil, s, mcc) + }, nil, nil, "default", false, nil, s, mcc) assert.NoError(t, mcc.Run(stop)) go mockserviceController.Run(stop) clientset.RunAndWait(stop) @@ -138,12 +138,12 @@ func Test_KubeSecretController_ExternalIstiod_MultipleClusters(t *testing.T) { s := server.New() certWatcher := keycertbundle.NewWatcher() mcc := initController(clientset, testSecretNameSpace, stop) - mc := NewMulticluster("pilot-abc-123", clientset.Kube(), testSecretNameSpace, Options{ + mc := NewMulticluster("pilot-abc-123", Options{ ClusterID: "cluster-1", DomainSuffix: DomainSuffix, MeshWatcher: mesh.NewFixedWatcher(&meshconfig.MeshConfig{}), MeshServiceController: mockserviceController, - }, nil, nil, certWatcher, "default", false, nil, s, mcc) + }, nil, certWatcher, "default", false, nil, s, mcc) assert.NoError(t, mcc.Run(stop)) go mockserviceController.Run(stop) clientset.RunAndWait(stop)