Skip to content

Commit

Permalink
Pass clusterCacheTrackerClientQPS/clusterCacheTrackerClientBurst to m…
Browse files Browse the repository at this point in the history
…anager

Signed-off-by: Furkat Gofurov <furkat.gofurov@suse.com>
  • Loading branch information
furkatgofurov7 committed Nov 11, 2024
1 parent 3cb134a commit cfbca75
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
2 changes: 2 additions & 0 deletions bootstrap/internal/controllers/rke2config_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
kubeyaml "sigs.k8s.io/yaml"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/controllers/remote"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/annotations"
"sigs.k8s.io/cluster-api/util/conditions"
Expand All @@ -63,6 +64,7 @@ const (
// RKE2ConfigReconciler reconciles a Rke2Config object.
type RKE2ConfigReconciler struct {
RKE2InitLock RKE2InitLock
Tracker *remote.ClusterCacheTracker
client.Client
Scheme *runtime.Scheme
}
Expand Down
32 changes: 30 additions & 2 deletions bootstrap/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/controllers/remote"
"sigs.k8s.io/cluster-api/util/flags"

bootstrapv1alpha1 "github.com/rancher/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
Expand Down Expand Up @@ -226,9 +227,36 @@ func setupChecks(mgr ctrl.Manager) {
}

func setupReconcilers(mgr ctrl.Manager) {
secretCachingClient, err := client.New(mgr.GetConfig(), client.Options{
HTTPClient: mgr.GetHTTPClient(),
Cache: &client.CacheOptions{
Reader: mgr.GetCache(),
},
})
if err != nil {
setupLog.Error(err, "Unable to create secret caching client")
os.Exit(1)
}

tracker, err := remote.NewClusterCacheTracker(
mgr,
remote.ClusterCacheTrackerOptions{
SecretCachingClient: secretCachingClient,
ControllerName: "rke2-bootstrap-controller",
Log: &ctrl.Log,
ClientQPS: clusterCacheTrackerClientQPS,
ClientBurst: clusterCacheTrackerClientBurst,
},
)
if err != nil {
setupLog.Error(err, "Unable to create cluster cache tracker")
os.Exit(1)
}

if err := (&controllers.RKE2ConfigReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Tracker: tracker,
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Rke2Config")
os.Exit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func patchRKE2ControlPlane(ctx context.Context, patchHelper *patch.Helper, rcp *
}

// SetupWithManager sets up the controller with the Manager.
func (r *RKE2ControlPlaneReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error {
func (r *RKE2ControlPlaneReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, clientQPS float32, clientBurst int) error {
c, err := ctrl.NewControllerManagedBy(mgr).
For(&controlplanev1.RKE2ControlPlane{}).
Owns(&clusterv1.Machine{}).
Expand Down Expand Up @@ -257,6 +257,8 @@ func (r *RKE2ControlPlaneReconciler) SetupWithManager(ctx context.Context, mgr c
&corev1.ConfigMap{},
&corev1.Secret{},
},
ClientQPS: clientQPS,
ClientBurst: clientBurst,
},
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion controlplane/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) {
Scheme: mgr.GetScheme(),
WatchFilterValue: watchFilterValue,
SecretCachingClient: secretCachingClient,
}).SetupWithManager(ctx, mgr); err != nil {
}).SetupWithManager(ctx, mgr, clusterCacheTrackerClientQPS, clusterCacheTrackerClientBurst); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "RKE2ControlPlane")
os.Exit(1)
}
Expand Down

0 comments on commit cfbca75

Please sign in to comment.