Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose reconcile concurrency as a command flag #67

Merged
merged 1 commit into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ray-operator/controllers/raycluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
controller "sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/handler"
logf "sigs.k8s.io/controller-runtime/pkg/log"
Expand Down Expand Up @@ -376,7 +377,7 @@ func (r *RayClusterReconciler) buildWorkerPod(instance rayiov1alpha1.RayCluster,
}

// SetupWithManager builds the reconciler.
func (r *RayClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
func (r *RayClusterReconciler) SetupWithManager(mgr ctrl.Manager, reconcileConcurrency int) error {
return ctrl.NewControllerManagedBy(mgr).
For(&rayiov1alpha1.RayCluster{}).Named("raycluster-controller").
Watches(&source.Kind{Type: &corev1.Pod{}}, &handler.EnqueueRequestForOwner{
Expand All @@ -387,6 +388,7 @@ func (r *RayClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
IsController: true,
OwnerType: &rayiov1alpha1.RayCluster{},
}).
WithOptions(controller.Options{MaxConcurrentReconciles: reconcileConcurrency}).
Complete(r)
}

Expand Down
2 changes: 1 addition & 1 deletion ray-operator/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var _ = BeforeSuite(func(done Done) {
})
Expect(err).NotTo(HaveOccurred(), "failed to create manager")

err = NewReconciler(mgr).SetupWithManager(mgr)
err = NewReconciler(mgr).SetupWithManager(mgr, 1)
Expect(err).NotTo(HaveOccurred(), "failed to setup controller")

go func() {
Expand Down
5 changes: 4 additions & 1 deletion ray-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"flag"
"os"

"sigs.k8s.io/controller-runtime/pkg/healthz"

"github.com/ray-project/kuberay/ray-operator/controllers"
Expand Down Expand Up @@ -32,10 +33,12 @@ func main() {
var metricsAddr string
var enableLeaderElection bool
var probeAddr string
var reconcileConcurrency int
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")
flag.IntVar(&reconcileConcurrency, "reconcile-concurrency", 1, "max concurrency for reconciling")
opts := zap.Options{
Development: true,
}
Expand All @@ -59,7 +62,7 @@ func main() {
os.Exit(1)
}

if err = controllers.NewReconciler(mgr).SetupWithManager(mgr); err != nil {
if err = controllers.NewReconciler(mgr).SetupWithManager(mgr, reconcileConcurrency); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "RayCluster")
os.Exit(1)
}
Expand Down