From 0d6c3d113bd9957185b89aa12d19b2772dea3ddc Mon Sep 17 00:00:00 2001 From: jianrongzhang89 Date: Thu, 5 Sep 2024 21:24:44 -0700 Subject: [PATCH] [issue-368] knative integration with DataIndex and JobService: fix workflow deletion hanging issue --- .../common/constants/platform_services.go | 1 - controllers/sonataflow_controller.go | 28 ++++++------------- controllers/sonataflowplatform_controller.go | 24 ++++++---------- 3 files changed, 18 insertions(+), 35 deletions(-) diff --git a/controllers/profiles/common/constants/platform_services.go b/controllers/profiles/common/constants/platform_services.go index 9ba7c4e6d..4416ed7d3 100644 --- a/controllers/profiles/common/constants/platform_services.go +++ b/controllers/profiles/common/constants/platform_services.go @@ -37,7 +37,6 @@ const ( JobServiceJobEventsPath = "/v2/jobs/events" JobServiceLeaderCheckExpirationInSeconds = "kogito.jobs-service.management.leader-check.expiration-in-seconds" DefaultJobServiceLeaderCheckExpirationInSeconds = "60" - JobServiceRequestEventsURL = "mp.messaging.outgoing.kogito-job-service-job-request-events.url" KogitoProcessInstancesEventsConnector = "mp.messaging.outgoing.kogito-processinstances-events.connector" KogitoProcessInstancesEventsMethod = "mp.messaging.outgoing.kogito-processinstances-events.method" diff --git a/controllers/sonataflow_controller.go b/controllers/sonataflow_controller.go index 3436cff0c..ccd12e833 100644 --- a/controllers/sonataflow_controller.go +++ b/controllers/sonataflow_controller.go @@ -128,25 +128,15 @@ func (r *SonataFlowReconciler) setDefaults(workflow *operatorapi.SonataFlow) { } func (r *SonataFlowReconciler) cleanupTriggers(ctx context.Context, workflow *operatorapi.SonataFlow) error { - plf, _ := platform.GetActivePlatform(ctx, r.Client, workflow.Namespace) - if plf == nil || len(plf.Status.Triggers) == 0 { - return nil - } - avail, err := knative.GetKnativeAvailability(r.Config) - if err != nil { - return err - } - if avail.Eventing { - for _, triggerRef := range workflow.Status.Triggers { - trigger := &eventingv1.Trigger{ - ObjectMeta: metav1.ObjectMeta{ - Name: triggerRef.Name, - Namespace: triggerRef.Namespace, - }, - } - if err := r.Client.Delete(ctx, trigger); err != nil { - return err - } + for _, triggerRef := range workflow.Status.Triggers { + trigger := &eventingv1.Trigger{ + ObjectMeta: metav1.ObjectMeta{ + Name: triggerRef.Name, + Namespace: triggerRef.Namespace, + }, + } + if err := r.Client.Delete(ctx, trigger); err != nil && !errors.IsNotFound(err) { + return err } } controllerutil.RemoveFinalizer(workflow, constants.TriggerFinalizer) diff --git a/controllers/sonataflowplatform_controller.go b/controllers/sonataflowplatform_controller.go index a6887dac1..1c0db0f35 100644 --- a/controllers/sonataflowplatform_controller.go +++ b/controllers/sonataflowplatform_controller.go @@ -185,21 +185,15 @@ func (r *SonataFlowPlatformReconciler) Reconcile(ctx context.Context, req reconc } func (r *SonataFlowPlatformReconciler) cleanupTriggers(ctx context.Context, platform *operatorapi.SonataFlowPlatform) error { - avail, err := knative.GetKnativeAvailability(r.Config) - if err != nil { - return err - } - if avail.Eventing { - for _, triggerRef := range platform.Status.Triggers { - trigger := &eventingv1.Trigger{ - ObjectMeta: metav1.ObjectMeta{ - Name: triggerRef.Name, - Namespace: triggerRef.Namespace, - }, - } - if err := r.Client.Delete(ctx, trigger); err != nil { - return err - } + for _, triggerRef := range platform.Status.Triggers { + trigger := &eventingv1.Trigger{ + ObjectMeta: metav1.ObjectMeta{ + Name: triggerRef.Name, + Namespace: triggerRef.Namespace, + }, + } + if err := r.Client.Delete(ctx, trigger); err != nil && !errors.IsNotFound(err) { + return err } } controllerutil.RemoveFinalizer(platform, constants.TriggerFinalizer)