Skip to content

Commit

Permalink
add resync period option
Browse files Browse the repository at this point in the history
Signed-off-by: Garrybest <[email protected]>
  • Loading branch information
Garrybest committed Jan 22, 2022
1 parent 499dcaa commit 012f0ca
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
5 changes: 1 addition & 4 deletions cmd/agent/app/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"flag"
"fmt"
"os"
"time"

"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -116,11 +115,9 @@ func run(ctx context.Context, karmadaConfig karmadactl.KarmadaConfig, opts *opti
return err
}

// TODO(Garrybest): add resyncPeriod to options
resyncPeriod := time.Duration(0)
controllerManager, err := controllerruntime.NewManager(controlPlaneRestConfig, controllerruntime.Options{
Scheme: gclient.NewSchema(),
SyncPeriod: &resyncPeriod,
SyncPeriod: &opts.ResyncPeriod.Duration,
Namespace: executionSpace,
LeaderElection: opts.LeaderElection.LeaderElect,
LeaderElectionID: fmt.Sprintf("karmada-agent-%s", opts.ClusterName),
Expand Down
4 changes: 4 additions & 0 deletions cmd/agent/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ type Options struct {
KubeAPIBurst int

ClusterCacheSyncTimeout metav1.Duration
// ResyncPeriod is the base frequency the informers are resynced.
// Defaults to 0, which means the created informer will never do resyncs.
ResyncPeriod metav1.Duration

// ClusterAPIEndpoint holds the apiEndpoint of the cluster.
ClusterAPIEndpoint string
Expand Down Expand Up @@ -93,4 +96,5 @@ func (o *Options) AddFlags(fs *pflag.FlagSet, allControllers []string) {
fs.DurationVar(&o.ClusterCacheSyncTimeout.Duration, "cluster-cache-sync-timeout", util.CacheSyncTimeout, "Timeout period waiting for cluster cache to sync.")
fs.StringVar(&o.ClusterAPIEndpoint, "cluster-api-endpoint", o.ClusterAPIEndpoint, "APIEndpoint of the cluster.")
fs.StringVar(&o.ProxyServerAddress, "proxy-server-address", o.ProxyServerAddress, "Address of the proxy server that is used to proxy to the cluster.")
fs.DurationVar(&o.ResyncPeriod.Duration, "resync-period", 0, "Base frequency the informers are resynced.")
}
5 changes: 1 addition & 4 deletions cmd/controller-manager/app/controllermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net"
"os"
"strconv"
"time"

"github.com/spf13/cobra"
"k8s.io/client-go/discovery"
Expand Down Expand Up @@ -75,11 +74,9 @@ func Run(ctx context.Context, opts *options.Options) error {
panic(err)
}
config.QPS, config.Burst = opts.KubeAPIQPS, opts.KubeAPIBurst
// TODO(Garrybest): add resyncPeriod to options
resyncPeriod := time.Duration(0)
controllerManager, err := controllerruntime.NewManager(config, controllerruntime.Options{
Scheme: gclient.NewSchema(),
SyncPeriod: &resyncPeriod,
SyncPeriod: &opts.ResyncPeriod.Duration,
LeaderElection: opts.LeaderElection.LeaderElect,
LeaderElectionID: opts.LeaderElection.ResourceName,
LeaderElectionNamespace: opts.LeaderElection.ResourceNamespace,
Expand Down
4 changes: 4 additions & 0 deletions cmd/controller-manager/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ type Options struct {
KubeAPIBurst int
// ClusterCacheSyncTimeout is the timeout period waiting for cluster cache to sync
ClusterCacheSyncTimeout metav1.Duration
// ResyncPeriod is the base frequency the informers are resynced.
// Defaults to 0, which means the created informer will never do resyncs.
ResyncPeriod metav1.Duration
}

// NewOptions builds an empty options.
Expand Down Expand Up @@ -122,4 +125,5 @@ func (o *Options) AddFlags(flags *pflag.FlagSet, allControllers []string) {
flags.Float32Var(&o.KubeAPIQPS, "kube-api-qps", 40.0, "QPS to use while talking with karmada-apiserver. Doesn't cover events and node heartbeat apis which rate limiting is controlled by a different set of flags.")
flags.IntVar(&o.KubeAPIBurst, "kube-api-burst", 60, "Burst to use while talking with karmada-apiserver. Doesn't cover events and node heartbeat apis which rate limiting is controlled by a different set of flags.")
flags.DurationVar(&o.ClusterCacheSyncTimeout.Duration, "cluster-cache-sync-timeout", util.CacheSyncTimeout, "Timeout period waiting for cluster cache to sync.")
flags.DurationVar(&o.ResyncPeriod.Duration, "resync-period", 0, "Base frequency the informers are resynced.")
}

0 comments on commit 012f0ca

Please sign in to comment.