diff --git a/internal/controller/atlasmigration_controller.go b/internal/controller/atlasmigration_controller.go index 3f9b5ac..2d03bb9 100644 --- a/internal/controller/atlasmigration_controller.go +++ b/internal/controller/atlasmigration_controller.go @@ -24,17 +24,19 @@ import ( "fmt" "io" "net/url" + "runtime" "strings" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" + k8sruntime "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/predicate" "ariga.io/atlas-go-sdk/atlasexec" @@ -55,7 +57,7 @@ type ( // AtlasMigrationReconciler reconciles a AtlasMigration object AtlasMigrationReconciler struct { client.Client - scheme *runtime.Scheme + scheme *k8sruntime.Scheme atlasClient AtlasExecFn configMapWatcher *watch.ResourceWatcher secretWatcher *watch.ResourceWatcher @@ -204,6 +206,9 @@ func (r *AtlasMigrationReconciler) storeDirState(ctx context.Context, obj client // SetupWithManager sets up the controller with the Manager. func (r *AtlasMigrationReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). + WithOptions(controller.Options{ + MaxConcurrentReconciles: runtime.NumCPU(), + }). For(&dbv1alpha1.AtlasMigration{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). Owns(&dbv1alpha1.AtlasMigration{}). Watches(&corev1.Secret{}, r.secretWatcher). diff --git a/internal/controller/atlasschema_controller.go b/internal/controller/atlasschema_controller.go index faa61f8..c0b90c5 100644 --- a/internal/controller/atlasschema_controller.go +++ b/internal/controller/atlasschema_controller.go @@ -25,17 +25,19 @@ import ( "net/url" "path" "path/filepath" + "runtime" "strconv" "strings" "time" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/runtime" + k8sruntime "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/predicate" @@ -60,7 +62,7 @@ type ( AtlasSchemaReconciler struct { client.Client atlasClient AtlasExecFn - scheme *runtime.Scheme + scheme *k8sruntime.Scheme configMapWatcher *watch.ResourceWatcher secretWatcher *watch.ResourceWatcher recorder record.EventRecorder @@ -485,6 +487,9 @@ func (r *AtlasSchemaReconciler) Reconcile(ctx context.Context, req ctrl.Request) // SetupWithManager sets up the controller with the Manager. func (r *AtlasSchemaReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). + WithOptions(controller.Options{ + MaxConcurrentReconciles: runtime.NumCPU(), + }). For(&dbv1alpha1.AtlasSchema{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). Owns(&dbv1alpha1.AtlasSchema{}). Watches(&corev1.ConfigMap{}, r.configMapWatcher).