comment out
Some checks failed
Tests / Run on Ubuntu (push) Failing after 56s
Lint / Run on Ubuntu (push) Failing after 1m14s
Build images / Build docker image (push) Failing after 2m41s

This commit is contained in:
Chris Richardson
2025-07-03 13:05:45 -04:00
parent 039fea048c
commit 69f2af2549
4 changed files with 36 additions and 43 deletions

View File

@@ -18,12 +18,16 @@ package controller
import (
"context"
apps "k8s.io/api/apps/v1"
batch "k8s.io/api/batch/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/event"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
locustiov1alpha1 "git.lilpenguins.com/crichardson/locust-operator/api/v1alpha1"
)
@@ -83,9 +87,36 @@ func (r *LocustClusterReconciler) Reconcile(ctx context.Context, req ctrl.Reques
}
// SetupWithManager sets up the controller with the Manager.
func (r *LocustClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
func (r *LocustClusterReconciler) SetupWithManager(mgr ctrl.Manager, ctx context.Context) error {
/*
return ctrl.NewControllerManagedBy(mgr).
For(&locustiov1alpha1.LocustCluster{}).
Named("locustcluster").
Complete(r)
*/
log := logf.FromContext(ctx).WithValues()
ns := "default"
predLocustCluster := predicate.Funcs{
UpdateFunc: func(e event.UpdateEvent) bool {
log.Info("UpdateFunc", "kind", "LocustCluster", "process event", true, "event.namespace", e.ObjectNew.GetNamespace(), "event.name", e.ObjectNew.GetName(), "currentNamespace", ns)
return true
},
CreateFunc: func(e event.CreateEvent) bool {
log.Info("CreateFunc", "kind", "LocustCluster", "process event", true, "event.namespace", e.Object.GetNamespace(), "event.name", e.Object.GetName(), "currentNamespace", ns)
return true
},
DeleteFunc: func(e event.DeleteEvent) bool {
log.Info("DeleteFunc", "kind", "LocustCluster", "process event", false, "event.namespace", e.Object.GetNamespace(), "event.name", e.Object.GetName(), "currentNamespace", ns)
return false
},
}
return ctrl.NewControllerManagedBy(mgr).
For(&locustiov1alpha1.LocustCluster{}).
Named("locustcluster").
Owns(&batch.Job{}).
Owns(&apps.Deployment{}).
WithEventFilter(predLocustCluster).
WithOptions(controller.Options{MaxConcurrentReconciles: MaxConcurrentReconciles}).
Complete(r)
}