diff --git a/cmd/agent/app/agent.go b/cmd/agent/app/agent.go index 036dbf86d2d7..d71893d446d8 100644 --- a/cmd/agent/app/agent.go +++ b/cmd/agent/app/agent.go @@ -196,8 +196,7 @@ func run(ctx context.Context, opts *options.Options) error { controllerManager, err := controllerruntime.NewManager(controlPlaneRestConfig, controllerruntime.Options{ Scheme: gclient.NewSchema(), - SyncPeriod: &opts.ResyncPeriod.Duration, - Namespace: executionSpace, + Cache: cache.Options{SyncPeriod: &opts.ResyncPeriod.Duration, Namespaces: []string{executionSpace}}, LeaderElection: opts.LeaderElection.LeaderElect, LeaderElectionID: fmt.Sprintf("karmada-agent-%s", opts.ClusterName), LeaderElectionNamespace: opts.LeaderElection.ResourceNamespace, diff --git a/cmd/controller-manager/app/controllermanager.go b/cmd/controller-manager/app/controllermanager.go index 02d330f9e873..89207dc15b6d 100644 --- a/cmd/controller-manager/app/controllermanager.go +++ b/cmd/controller-manager/app/controllermanager.go @@ -145,7 +145,7 @@ func Run(ctx context.Context, opts *options.Options) error { controllerManager, err := controllerruntime.NewManager(controlPlaneRestConfig, controllerruntime.Options{ Logger: klog.Background(), Scheme: gclient.NewSchema(), - SyncPeriod: &opts.ResyncPeriod.Duration, + Cache: cache.Options{SyncPeriod: &opts.ResyncPeriod.Duration}, LeaderElection: opts.LeaderElection.LeaderElect, LeaderElectionID: opts.LeaderElection.ResourceName, LeaderElectionNamespace: opts.LeaderElection.ResourceNamespace,