From 2186371ace09919338c5b6efe0400377e1aa95a3 Mon Sep 17 00:00:00 2001 From: yokawasa Date: Thu, 23 Dec 2021 16:04:35 +0900 Subject: [PATCH 1/3] suppress delete events in SetupWith Manager --- controllers/gatling_controller.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/controllers/gatling_controller.go b/controllers/gatling_controller.go index c1242ef..1f51792 100644 --- a/controllers/gatling_controller.go +++ b/controllers/gatling_controller.go @@ -919,10 +919,16 @@ func (r *GatlingReconciler) getResultsDirectoryPath(gatling *gatlingv1alpha1.Gat return path } -// TODO: filter on create, update // SetupWithManager sets up the controller with the Manager. func (r *GatlingReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). For(&gatlingv1alpha1.Gatling{}). + WithEventFilter(predicate.Funcs{ + DeleteFunc: func(e event.DeleteEvent) bool { + // Suppress Delete events as we don't take any action in the reconiliation loop + // when invoked after the gatlingv1alpha1.Gatling is actually deleted + return false + }, + }). Complete(r) } From f33e4bccbe579fc6c394aa1e763171ebfc7e9e83 Mon Sep 17 00:00:00 2001 From: yokawasa Date: Thu, 23 Dec 2021 16:05:23 +0900 Subject: [PATCH 2/3] add dependant packages: event and predicate --- controllers/gatling_controller.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/controllers/gatling_controller.go b/controllers/gatling_controller.go index 1f51792..2100b00 100644 --- a/controllers/gatling_controller.go +++ b/controllers/gatling_controller.go @@ -29,6 +29,8 @@ import ( "k8s.io/apimachinery/pkg/util/rand" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/event" + "sigs.k8s.io/controller-runtime/pkg/predicate" gatlingv1alpha1 "github.com/st-tech/gatling-operator/api/v1alpha1" batchv1 "k8s.io/api/batch/v1" From 50f70f58a5b38d8424bd57cf714fcc3a337c05cb Mon Sep 17 00:00:00 2001 From: yokawasa Date: Thu, 23 Dec 2021 16:22:54 +0900 Subject: [PATCH 3/3] fix typo --- controllers/gatling_controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/gatling_controller.go b/controllers/gatling_controller.go index 2100b00..a4024a8 100644 --- a/controllers/gatling_controller.go +++ b/controllers/gatling_controller.go @@ -927,7 +927,7 @@ func (r *GatlingReconciler) SetupWithManager(mgr ctrl.Manager) error { For(&gatlingv1alpha1.Gatling{}). WithEventFilter(predicate.Funcs{ DeleteFunc: func(e event.DeleteEvent) bool { - // Suppress Delete events as we don't take any action in the reconiliation loop + // Suppress Delete events as we don't take any action in the reconciliation loop // when invoked after the gatlingv1alpha1.Gatling is actually deleted return false },