From 8c973adfd8416e980893b9f3dcd3c8ba48a79d41 Mon Sep 17 00:00:00 2001 From: Mohamed Awnallah Date: Wed, 4 Dec 2024 19:50:25 +0200 Subject: [PATCH] cmd+hack+operator+pkg: unify addons constants In this commit we unify the usage of addon names i.e `karmada-descheduler`, `karmada-scheduler-estimator`, `karmada-search`, and `karmada-metrics-adapter` across the codebase. Signed-off-by: Mohamed Awnallah --- cmd/descheduler/app/descheduler.go | 5 +++-- cmd/descheduler/app/descheduler_test.go | 3 ++- cmd/descheduler/app/options/options.go | 5 +++-- cmd/karmada-search/app/karmada-search.go | 8 +++++--- cmd/metrics-adapter/app/metrics-adapter.go | 5 +++-- cmd/metrics-adapter/app/options/options.go | 3 ++- cmd/scheduler-estimator/app/scheduler-estimator.go | 5 +++-- cmd/scheduler/app/options/options.go | 3 ++- hack/tools/gencomponentdocs/gen_component_docs.go | 9 +++++---- operator/pkg/constants/constants.go | 8 +++++--- pkg/descheduler/descheduler.go | 3 ++- pkg/karmadactl/addons/install/install.go | 8 ++++---- pkg/karmadactl/addons/install/install_test.go | 8 ++++---- pkg/search/apiserver.go | 3 ++- pkg/search/proxy/controller.go | 3 ++- 15 files changed, 47 insertions(+), 32 deletions(-) mode change 100755 => 100644 cmd/metrics-adapter/app/metrics-adapter.go diff --git a/cmd/descheduler/app/descheduler.go b/cmd/descheduler/app/descheduler.go index 4c17a4033bc3..c36f42a4bfa5 100644 --- a/cmd/descheduler/app/descheduler.go +++ b/cmd/descheduler/app/descheduler.go @@ -39,6 +39,7 @@ import ( "github.com/karmada-io/karmada/cmd/descheduler/app/options" "github.com/karmada-io/karmada/pkg/descheduler" karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" + addonsinit "github.com/karmada-io/karmada/pkg/karmadactl/addons/init" "github.com/karmada-io/karmada/pkg/sharedcli" "github.com/karmada-io/karmada/pkg/sharedcli/klogflag" "github.com/karmada-io/karmada/pkg/sharedcli/profileflag" @@ -80,7 +81,7 @@ func NewDeschedulerCommand(stopChan <-chan struct{}) *cobra.Command { opts := options.NewOptions() cmd := &cobra.Command{ - Use: "karmada-descheduler", + Use: addonsinit.DeschedulerResourceName, Long: `The karmada-descheduler evicts replicas from member clusters if they are failed to be scheduled for a period of time. It relies on karmada-scheduler-estimator to get replica status.`, @@ -113,7 +114,7 @@ karmada-scheduler-estimator to get replica status.`, logsFlagSet := fss.FlagSet("logs") klogflag.Add(logsFlagSet) - cmd.AddCommand(sharedcommand.NewCmdVersion("karmada-descheduler")) + cmd.AddCommand(sharedcommand.NewCmdVersion(addonsinit.DeschedulerResourceName)) cmd.Flags().AddFlagSet(genericFlagSet) cmd.Flags().AddFlagSet(logsFlagSet) diff --git a/cmd/descheduler/app/descheduler_test.go b/cmd/descheduler/app/descheduler_test.go index 5d787f7d781c..3a75909bd6d5 100644 --- a/cmd/descheduler/app/descheduler_test.go +++ b/cmd/descheduler/app/descheduler_test.go @@ -25,6 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/karmada-io/karmada/cmd/descheduler/app/options" + addonsinit "github.com/karmada-io/karmada/pkg/karmadactl/addons/init" ) func TestNewDeschedulerCommand(t *testing.T) { @@ -32,7 +33,7 @@ func TestNewDeschedulerCommand(t *testing.T) { cmd := NewDeschedulerCommand(stopCh) assert.NotNil(t, cmd) - assert.Equal(t, "karmada-descheduler", cmd.Use) + assert.Equal(t, addonsinit.DeschedulerResourceName, cmd.Use) assert.NotEmpty(t, cmd.Long) } diff --git a/cmd/descheduler/app/options/options.go b/cmd/descheduler/app/options/options.go index 73e9abdb8587..a3caa38164c6 100644 --- a/cmd/descheduler/app/options/options.go +++ b/cmd/descheduler/app/options/options.go @@ -24,6 +24,7 @@ import ( "k8s.io/client-go/tools/leaderelection/resourcelock" componentbaseconfig "k8s.io/component-base/config" + addonsinit "github.com/karmada-io/karmada/pkg/karmadactl/addons/init" "github.com/karmada-io/karmada/pkg/sharedcli/profileflag" "github.com/karmada-io/karmada/pkg/util" ) @@ -90,7 +91,7 @@ func NewOptions() *Options { LeaderElect: true, ResourceLock: resourcelock.LeasesResourceLock, ResourceNamespace: util.NamespaceKarmadaSystem, - ResourceName: "karmada-descheduler", + ResourceName: addonsinit.DeschedulerResourceName, LeaseDuration: defaultElectionLeaseDuration, RenewDeadline: defaultElectionRenewDeadline, RetryPeriod: defaultElectionRetryPeriod, @@ -129,7 +130,7 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&o.SchedulerEstimatorCaFile, "scheduler-estimator-ca-file", "", "SSL Certificate Authority file used to secure scheduler estimator communication.") fs.BoolVar(&o.InsecureSkipEstimatorVerify, "insecure-skip-estimator-verify", false, "Controls whether verifies the scheduler estimator's certificate chain and host name.") fs.StringVar(&o.SchedulerEstimatorServiceNamespace, "scheduler-estimator-service-namespace", util.NamespaceKarmadaSystem, "The namespace to be used for discovering scheduler estimator services.") - fs.StringVar(&o.SchedulerEstimatorServicePrefix, "scheduler-estimator-service-prefix", "karmada-scheduler-estimator", "The prefix of scheduler estimator service name") + fs.StringVar(&o.SchedulerEstimatorServicePrefix, "scheduler-estimator-service-prefix", addonsinit.EstimatorResourceName, "The prefix of scheduler estimator service name") fs.DurationVar(&o.DeschedulingInterval.Duration, "descheduling-interval", defaultDeschedulingInterval, "Time interval between two consecutive descheduler executions. Setting this value instructs the descheduler to run in a continuous loop at the interval specified.") fs.DurationVar(&o.UnschedulableThreshold.Duration, "unschedulable-threshold", defaultUnschedulableThreshold, "The period of pod unschedulable condition. This value is considered as a classification standard of unschedulable replicas.") fs.StringVar(&o.MetricsBindAddress, "metrics-bind-address", ":8080", "The TCP address that the server should bind to for serving prometheus metrics(e.g. 127.0.0.1:8080, :8080). It can be set to \"0\" to disable the metrics serving. Defaults to 0.0.0.0:8080.") diff --git a/cmd/karmada-search/app/karmada-search.go b/cmd/karmada-search/app/karmada-search.go index 032e83f16f59..c306f0fcebb1 100644 --- a/cmd/karmada-search/app/karmada-search.go +++ b/cmd/karmada-search/app/karmada-search.go @@ -53,6 +53,8 @@ import ( "github.com/karmada-io/karmada/pkg/util/lifted" "github.com/karmada-io/karmada/pkg/version" "github.com/karmada-io/karmada/pkg/version/sharedcommand" + + addonsinit "github.com/karmada-io/karmada/pkg/karmadactl/addons/init" ) // Option configures a framework.Registry. @@ -63,7 +65,7 @@ func NewKarmadaSearchCommand(ctx context.Context, registryOptions ...Option) *co opts := options.NewOptions() cmd := &cobra.Command{ - Use: "karmada-search", + Use: addonsinit.SearchResourceName, Long: `The karmada-search starts an aggregated server. It provides capabilities such as global search and resource proxy in a multi-cloud environment.`, RunE: func(_ *cobra.Command, _ []string) error { @@ -89,7 +91,7 @@ capabilities such as global search and resource proxy in a multi-cloud environme logsFlagSet := fss.FlagSet("logs") klogflag.Add(logsFlagSet) - cmd.AddCommand(sharedcommand.NewCmdVersion("karmada-search")) + cmd.AddCommand(sharedcommand.NewCmdVersion(addonsinit.SearchResourceName)) cmd.Flags().AddFlagSet(genericFlagSet) cmd.Flags().AddFlagSet(logsFlagSet) @@ -173,7 +175,7 @@ func config(o *options.Options, outOfTreeRegistryOptions ...Option) (*search.Con sets.NewString("attach", "exec", "proxy", "log", "portforward")) serverConfig.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(generatedopenapi.GetOpenAPIDefinitions, openapi.NewDefinitionNamer(searchscheme.Scheme)) serverConfig.OpenAPIV3Config = genericapiserver.DefaultOpenAPIV3Config(generatedopenapi.GetOpenAPIDefinitions, openapi.NewDefinitionNamer(searchscheme.Scheme)) - serverConfig.OpenAPIConfig.Info.Title = "karmada-search" + serverConfig.OpenAPIConfig.Info.Title = addonsinit.SearchResourceName if err := o.ApplyTo(serverConfig); err != nil { return nil, err } diff --git a/cmd/metrics-adapter/app/metrics-adapter.go b/cmd/metrics-adapter/app/metrics-adapter.go old mode 100755 new mode 100644 index 7fbe0952b127..4c1cda983ea9 --- a/cmd/metrics-adapter/app/metrics-adapter.go +++ b/cmd/metrics-adapter/app/metrics-adapter.go @@ -25,6 +25,7 @@ import ( "k8s.io/component-base/term" "github.com/karmada-io/karmada/cmd/metrics-adapter/app/options" + addonsinit "github.com/karmada-io/karmada/pkg/karmadactl/addons/init" "github.com/karmada-io/karmada/pkg/sharedcli" "github.com/karmada-io/karmada/pkg/sharedcli/klogflag" "github.com/karmada-io/karmada/pkg/version/sharedcommand" @@ -35,7 +36,7 @@ func NewMetricsAdapterCommand(ctx context.Context) *cobra.Command { opts := options.NewOptions() cmd := &cobra.Command{ - Use: "karmada-metrics-adapter", + Use: addonsinit.MetricsAdapterResourceName, Long: `The karmada-metrics-adapter is a adapter to aggregate the metrics from member clusters.`, RunE: func(_ *cobra.Command, _ []string) error { if err := opts.Complete(); err != nil { @@ -68,7 +69,7 @@ func NewMetricsAdapterCommand(ctx context.Context) *cobra.Command { logsFlagSet := fss.FlagSet("logs") klogflag.Add(logsFlagSet) - cmd.AddCommand(sharedcommand.NewCmdVersion("karmada-metrics-adapter")) + cmd.AddCommand(sharedcommand.NewCmdVersion(addonsinit.MetricsAdapterResourceName)) cmd.Flags().AddFlagSet(genericFlagSet) cmd.Flags().AddFlagSet(logsFlagSet) diff --git a/cmd/metrics-adapter/app/options/options.go b/cmd/metrics-adapter/app/options/options.go index 95ef4f10022f..d7cb8c164c4a 100755 --- a/cmd/metrics-adapter/app/options/options.go +++ b/cmd/metrics-adapter/app/options/options.go @@ -32,6 +32,7 @@ import ( karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" informerfactory "github.com/karmada-io/karmada/pkg/generated/informers/externalversions" generatedopenapi "github.com/karmada-io/karmada/pkg/generated/openapi" + addonsinit "github.com/karmada-io/karmada/pkg/karmadactl/addons/init" "github.com/karmada-io/karmada/pkg/metricsadapter" "github.com/karmada-io/karmada/pkg/sharedcli/profileflag" "github.com/karmada-io/karmada/pkg/util" @@ -96,7 +97,7 @@ func (o *Options) Config(stopCh <-chan struct{}) (*metricsadapter.MetricsServer, metricsAdapter := metricsadapter.NewMetricsAdapter(metricsController, o.CustomMetricsAdapterServerOptions) metricsAdapter.OpenAPIConfig = genericapiserver.DefaultOpenAPIConfig(generatedopenapi.GetOpenAPIDefinitions, openapinamer.NewDefinitionNamer(api.Scheme)) metricsAdapter.OpenAPIV3Config = genericapiserver.DefaultOpenAPIV3Config(generatedopenapi.GetOpenAPIDefinitions, openapinamer.NewDefinitionNamer(api.Scheme)) - metricsAdapter.OpenAPIConfig.Info.Title = "karmada-metrics-adapter" + metricsAdapter.OpenAPIConfig.Info.Title = addonsinit.MetricsAdapterResourceName metricsAdapter.OpenAPIConfig.Info.Version = "1.0.0" // Explicitly specify the remote kubeconfig file here to solve the issue that metrics adapter requires to build diff --git a/cmd/scheduler-estimator/app/scheduler-estimator.go b/cmd/scheduler-estimator/app/scheduler-estimator.go index fed9ec40f4eb..38a6d9f3627a 100644 --- a/cmd/scheduler-estimator/app/scheduler-estimator.go +++ b/cmd/scheduler-estimator/app/scheduler-estimator.go @@ -36,6 +36,7 @@ import ( "github.com/karmada-io/karmada/cmd/scheduler-estimator/app/options" "github.com/karmada-io/karmada/pkg/estimator/server" + addonsinit "github.com/karmada-io/karmada/pkg/karmadactl/addons/init" "github.com/karmada-io/karmada/pkg/sharedcli" "github.com/karmada-io/karmada/pkg/sharedcli/klogflag" "github.com/karmada-io/karmada/pkg/sharedcli/profileflag" @@ -77,7 +78,7 @@ func NewSchedulerEstimatorCommand(ctx context.Context) *cobra.Command { opts := options.NewOptions() cmd := &cobra.Command{ - Use: "karmada-scheduler-estimator", + Use: addonsinit.EstimatorResourceName, Long: `The karmada-scheduler-estimator runs an accurate scheduler estimator of a cluster. It provides the scheduler with more accurate cluster resource information.`, RunE: func(_ *cobra.Command, _ []string) error { @@ -101,7 +102,7 @@ provides the scheduler with more accurate cluster resource information.`, logsFlagSet := fss.FlagSet("logs") klogflag.Add(logsFlagSet) - cmd.AddCommand(sharedcommand.NewCmdVersion("karmada-scheduler-estimator")) + cmd.AddCommand(sharedcommand.NewCmdVersion(addonsinit.EstimatorResourceName)) cmd.Flags().AddFlagSet(genericFlagSet) cmd.Flags().AddFlagSet(logsFlagSet) diff --git a/cmd/scheduler/app/options/options.go b/cmd/scheduler/app/options/options.go index 36f67044763e..17d326fa0c4e 100644 --- a/cmd/scheduler/app/options/options.go +++ b/cmd/scheduler/app/options/options.go @@ -27,6 +27,7 @@ import ( componentbaseconfig "k8s.io/component-base/config" "github.com/karmada-io/karmada/pkg/features" + addonsinit "github.com/karmada-io/karmada/pkg/karmadactl/addons/init" "github.com/karmada-io/karmada/pkg/scheduler" frameworkplugins "github.com/karmada-io/karmada/pkg/scheduler/framework/plugins" "github.com/karmada-io/karmada/pkg/sharedcli/profileflag" @@ -153,7 +154,7 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) { fs.BoolVar(&o.DisableSchedulerEstimatorInPullMode, "disable-scheduler-estimator-in-pull-mode", false, "Disable the scheduler estimator for clusters in pull mode, which takes effect only when enable-scheduler-estimator is true.") fs.DurationVar(&o.SchedulerEstimatorTimeout.Duration, "scheduler-estimator-timeout", 3*time.Second, "Specifies the timeout period of calling the scheduler estimator service.") fs.StringVar(&o.SchedulerEstimatorServiceNamespace, "scheduler-estimator-service-namespace", util.NamespaceKarmadaSystem, "The namespace to be used for discovering scheduler estimator services.") - fs.StringVar(&o.SchedulerEstimatorServicePrefix, "scheduler-estimator-service-prefix", "karmada-scheduler-estimator", "The prefix of scheduler estimator service name") + fs.StringVar(&o.SchedulerEstimatorServicePrefix, "scheduler-estimator-service-prefix", addonsinit.EstimatorResourceName, "The prefix of scheduler estimator service name") fs.IntVar(&o.SchedulerEstimatorPort, "scheduler-estimator-port", defaultEstimatorPort, "The secure port on which to connect the accurate scheduler estimator.") fs.StringVar(&o.SchedulerEstimatorCertFile, "scheduler-estimator-cert-file", "", "SSL certification file used to secure scheduler estimator communication.") fs.StringVar(&o.SchedulerEstimatorKeyFile, "scheduler-estimator-key-file", "", "SSL key file used to secure scheduler estimator communication.") diff --git a/hack/tools/gencomponentdocs/gen_component_docs.go b/hack/tools/gencomponentdocs/gen_component_docs.go index fc6df12dfb71..be64a1f8b116 100644 --- a/hack/tools/gencomponentdocs/gen_component_docs.go +++ b/hack/tools/gencomponentdocs/gen_component_docs.go @@ -33,6 +33,7 @@ import ( estiapp "github.com/karmada-io/karmada/cmd/scheduler-estimator/app" schapp "github.com/karmada-io/karmada/cmd/scheduler/app" webhookapp "github.com/karmada-io/karmada/cmd/webhook/app" + addonsinit "github.com/karmada-io/karmada/pkg/karmadactl/addons/init" "github.com/karmada-io/karmada/pkg/util/lifted" ) @@ -69,19 +70,19 @@ func main() { case "karmada-aggregated-apiserver": // generate docs for karmada-aggregated-apiserver cmd = aaapp.NewAggregatedApiserverCommand(context.TODO()) - case "karmada-descheduler": + case addonsinit.DeschedulerResourceName: // generate docs for karmada-descheduler cmd = deschapp.NewDeschedulerCommand(nil) - case "karmada-search": + case addonsinit.SearchResourceName: // generate docs for karmada-search cmd = searchapp.NewKarmadaSearchCommand(context.TODO()) - case "karmada-scheduler-estimator": + case addonsinit.EstimatorResourceName: // generate docs for karmada-scheduler-estimator cmd = estiapp.NewSchedulerEstimatorCommand(context.TODO()) case "karmada-webhook": // generate docs for karmada-webhook cmd = webhookapp.NewWebhookCommand(context.TODO()) - case "karmada-metrics-adapter": + case addonsinit.MetricsAdapterResourceName: // generate docs for karmada-metrics-adapter cmd = adapterapp.NewMetricsAdapterCommand(context.TODO()) default: diff --git a/operator/pkg/constants/constants.go b/operator/pkg/constants/constants.go index 9982970a57a7..b840bf4bdcf1 100644 --- a/operator/pkg/constants/constants.go +++ b/operator/pkg/constants/constants.go @@ -21,6 +21,8 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime/schema" + + addonsinit "github.com/karmada-io/karmada/pkg/karmadactl/addons/init" ) const ( @@ -56,11 +58,11 @@ const ( // KarmadaWebhook defines the name of the karmada-webhook component KarmadaWebhook = "karmada-webhook" // KarmadaSearch defines the name of the karmada-search component - KarmadaSearch = "karmada-search" + KarmadaSearch = addonsinit.SearchResourceName // KarmadaDescheduler defines the name of the karmada-descheduler component - KarmadaDescheduler = "karmada-descheduler" + KarmadaDescheduler = addonsinit.DeschedulerResourceName // KarmadaMetricsAdapter defines the name of the karmada-metrics-adapter component - KarmadaMetricsAdapter = "karmada-metrics-adapter" + KarmadaMetricsAdapter = addonsinit.MetricsAdapterResourceName // KarmadaSystemNamespace defines the leader selection namespace for karmada components KarmadaSystemNamespace = "karmada-system" diff --git a/pkg/descheduler/descheduler.go b/pkg/descheduler/descheduler.go index 41fbafcf8678..a83b42d6642c 100644 --- a/pkg/descheduler/descheduler.go +++ b/pkg/descheduler/descheduler.go @@ -42,6 +42,7 @@ import ( informerfactory "github.com/karmada-io/karmada/pkg/generated/informers/externalversions" clusterlister "github.com/karmada-io/karmada/pkg/generated/listers/cluster/v1alpha1" worklister "github.com/karmada-io/karmada/pkg/generated/listers/work/v1alpha2" + addonsinit "github.com/karmada-io/karmada/pkg/karmadactl/addons/init" "github.com/karmada-io/karmada/pkg/util" "github.com/karmada-io/karmada/pkg/util/fedinformer" "github.com/karmada-io/karmada/pkg/util/gclient" @@ -131,7 +132,7 @@ func NewDescheduler(karmadaClient karmadaclientset.Interface, kubeClient kuberne eventBroadcaster := record.NewBroadcaster() eventBroadcaster.StartStructuredLogging(0) eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.CoreV1().Events(metav1.NamespaceAll)}) - desched.eventRecorder = eventBroadcaster.NewRecorder(gclient.NewSchema(), corev1.EventSource{Component: "karmada-descheduler"}) + desched.eventRecorder = eventBroadcaster.NewRecorder(gclient.NewSchema(), corev1.EventSource{Component: addonsinit.DeschedulerResourceName}) return desched } diff --git a/pkg/karmadactl/addons/install/install.go b/pkg/karmadactl/addons/install/install.go index a22671ac0a98..28c3fdcfe352 100644 --- a/pkg/karmadactl/addons/install/install.go +++ b/pkg/karmadactl/addons/install/install.go @@ -26,8 +26,8 @@ import ( // Install install the karmada addons process in Addons func Install() { - addonsinit.Addons["karmada-descheduler"] = descheduler.AddonDescheduler - addonsinit.Addons["karmada-metrics-adapter"] = metricsadapter.AddonMetricsAdapter - addonsinit.Addons["karmada-scheduler-estimator"] = estimator.AddonEstimator - addonsinit.Addons["karmada-search"] = search.AddonSearch + addonsinit.Addons[addonsinit.DeschedulerResourceName] = descheduler.AddonDescheduler + addonsinit.Addons[addonsinit.MetricsAdapterResourceName] = metricsadapter.AddonMetricsAdapter + addonsinit.Addons[addonsinit.EstimatorResourceName] = estimator.AddonEstimator + addonsinit.Addons[addonsinit.SearchResourceName] = search.AddonSearch } diff --git a/pkg/karmadactl/addons/install/install_test.go b/pkg/karmadactl/addons/install/install_test.go index 395281116e68..9cfd89a236e4 100644 --- a/pkg/karmadactl/addons/install/install_test.go +++ b/pkg/karmadactl/addons/install/install_test.go @@ -38,22 +38,22 @@ func TestInstall(t *testing.T) { }{ { name: "Install_WithKarmadaDeschedulerAddon_Installed", - key: "karmada-descheduler", + key: addonsinit.DeschedulerResourceName, expectedAddon: descheduler.AddonDescheduler, }, { name: "Install_WithKarmadaMetricsAdapterAddon_Installed", - key: "karmada-metrics-adapter", + key: addonsinit.MetricsAdapterResourceName, expectedAddon: metricsadapter.AddonMetricsAdapter, }, { name: "Install_WithKarmadaSchedulerEstimatorAddon_Installed", - key: "karmada-scheduler-estimator", + key: addonsinit.EstimatorResourceName, expectedAddon: estimator.AddonEstimator, }, { name: "Install_WithKarmadaSearchAddon_Installed", - key: "karmada-search", + key: addonsinit.SearchResourceName, expectedAddon: search.AddonSearch, }, } diff --git a/pkg/search/apiserver.go b/pkg/search/apiserver.go index 58ae79b711fd..a3dba9e5fd4b 100644 --- a/pkg/search/apiserver.go +++ b/pkg/search/apiserver.go @@ -27,6 +27,7 @@ import ( searchapis "github.com/karmada-io/karmada/pkg/apis/search" searchscheme "github.com/karmada-io/karmada/pkg/apis/search/scheme" informerfactory "github.com/karmada-io/karmada/pkg/generated/informers/externalversions" + addonsinit "github.com/karmada-io/karmada/pkg/karmadactl/addons/init" searchstorage "github.com/karmada-io/karmada/pkg/registry/search/storage" "github.com/karmada-io/karmada/pkg/search/proxy" ) @@ -79,7 +80,7 @@ var apiGroupInstaller = func(server *APIServer, apiGroupInfo *genericapiserver.A } func (c completedConfig) New() (*APIServer, error) { - genericServer, err := c.GenericConfig.New("karmada-search", genericapiserver.NewEmptyDelegate()) + genericServer, err := c.GenericConfig.New(addonsinit.SearchResourceName, genericapiserver.NewEmptyDelegate()) if err != nil { return nil, err } diff --git a/pkg/search/proxy/controller.go b/pkg/search/proxy/controller.go index c1b45dcdddf8..86d177553600 100644 --- a/pkg/search/proxy/controller.go +++ b/pkg/search/proxy/controller.go @@ -45,6 +45,7 @@ import ( informerfactory "github.com/karmada-io/karmada/pkg/generated/informers/externalversions" clusterlisters "github.com/karmada-io/karmada/pkg/generated/listers/cluster/v1alpha1" searchlisters "github.com/karmada-io/karmada/pkg/generated/listers/search/v1alpha1" + addonsinit "github.com/karmada-io/karmada/pkg/karmadactl/addons/init" "github.com/karmada-io/karmada/pkg/search/proxy/framework" "github.com/karmada-io/karmada/pkg/search/proxy/framework/plugins" pluginruntime "github.com/karmada-io/karmada/pkg/search/proxy/framework/runtime" @@ -299,7 +300,7 @@ func (ctl *Controller) Connect(ctx context.Context, proxyPath string, responder } h = metrics.InstrumentHandlerFunc(requestInfo.Verb, requestInfo.APIGroup, requestInfo.APIVersion, requestInfo.Resource, requestInfo.Subresource, - "", "karmada-search", false, "", h.ServeHTTP) + "", addonsinit.SearchResourceName, false, "", h.ServeHTTP) h.ServeHTTP(rw, newReq) }), nil }