diff --git a/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_prepostevaluation.go b/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_prepostevaluation.go index a66b707784..2e6953c2e1 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_prepostevaluation.go +++ b/lifecycle-operator/controllers/lifecycle/keptnappversion/reconcile_prepostevaluation.go @@ -15,8 +15,16 @@ func (r *KeptnAppVersionReconciler) reconcilePrePostEvaluation(ctx context.Conte SpanName: fmt.Sprintf(apicommon.CreateAppEvalSpanName, checkType), CheckType: checkType, } + evaluationHandler := evaluation.NewHandler( + r.Client, + r.EventSender, + r.Log, + r.getTracer(), + r.Client.Scheme(), + r.SpanHandler, + ) - newStatus, state, err := r.EvaluationHandler.ReconcileEvaluations(ctx, phaseCtx, appVersion, evaluationCreateAttributes) + newStatus, state, err := evaluationHandler.ReconcileEvaluations(ctx, phaseCtx, appVersion, evaluationCreateAttributes) if err != nil { return apicommon.StateUnknown, err } diff --git a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_prepostevaluation.go b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_prepostevaluation.go index 5694ebee1e..bf3e818dc9 100644 --- a/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_prepostevaluation.go +++ b/lifecycle-operator/controllers/lifecycle/keptnworkloadversion/reconcile_prepostevaluation.go @@ -16,7 +16,16 @@ func (r *KeptnWorkloadVersionReconciler) reconcilePrePostEvaluation(ctx context. CheckType: checkType, } - newStatus, state, err := r.EvaluationHandler.ReconcileEvaluations(ctx, phaseCtx, workloadVersion, evaluationCreateAttributes) + evaluationHandler := evaluation.NewHandler( + r.Client, + r.EventSender, + r.Log, + r.getTracer(), + r.Client.Scheme(), + r.SpanHandler, + ) + + newStatus, state, err := evaluationHandler.ReconcileEvaluations(ctx, phaseCtx, workloadVersion, evaluationCreateAttributes) if err != nil { return apicommon.StateUnknown, err } diff --git a/lifecycle-operator/main.go b/lifecycle-operator/main.go index c04be36378..8d0d58f94a 100644 --- a/lifecycle-operator/main.go +++ b/lifecycle-operator/main.go @@ -37,7 +37,6 @@ import ( lifecyclev1beta1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/lifecycle/v1beta1" optionsv1alpha1 "github.com/keptn/lifecycle-toolkit/lifecycle-operator/apis/options/v1alpha1" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/evaluation" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/phase" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/telemetry" @@ -56,7 +55,6 @@ import ( otelprom "go.opentelemetry.io/otel/exporters/prometheus" metricsapi "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/sdk/metric" - "go.opentelemetry.io/otel/trace/noop" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" @@ -279,14 +277,7 @@ func main() { workloadVersionLogger := ctrl.Log.WithName("KeptnWorkloadVersion Controller").V(env.KeptnWorkloadVersionControllerLogLevel) workloadVersionRecorder := mgr.GetEventRecorderFor("keptnworkloadversion-controller") workloadVersionEventSender := eventsender.NewEventMultiplexer(workloadVersionLogger, workloadVersionRecorder, ceClient) - workloadVersionEvaluationHandler := evaluation.NewHandler( - mgr.GetClient(), - workloadVersionEventSender, - workloadVersionLogger, - noop.NewTracerProvider().Tracer("keptn/lifecycle-operator/workloadversion"), - mgr.GetScheme(), - spanHandler, - ) + workloadVersionPhaseHandler := phase.NewHandler( mgr.GetClient(), workloadVersionEventSender, @@ -294,16 +285,15 @@ func main() { spanHandler, ) workloadVersionReconciler := &keptnworkloadversion.KeptnWorkloadVersionReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - Log: workloadVersionLogger, - EventSender: workloadVersionEventSender, - Meters: keptnMeters, - TracerFactory: telemetry.GetOtelInstance(), - SpanHandler: spanHandler, - EvaluationHandler: workloadVersionEvaluationHandler, - PhaseHandler: workloadVersionPhaseHandler, - Config: config.Instance(), + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + Log: workloadVersionLogger, + EventSender: workloadVersionEventSender, + Meters: keptnMeters, + TracerFactory: telemetry.GetOtelInstance(), + SpanHandler: spanHandler, + PhaseHandler: workloadVersionPhaseHandler, + Config: config.Instance(), } if err = (workloadVersionReconciler).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "KeptnWorkloadVersion") @@ -313,14 +303,7 @@ func main() { appVersionLogger := ctrl.Log.WithName("KeptnAppVersion Controller").V(env.KeptnAppVersionControllerLogLevel) appVersionRecorder := mgr.GetEventRecorderFor("keptnappversion-controller") appVersionEventSender := eventsender.NewEventMultiplexer(appVersionLogger, appVersionRecorder, ceClient) - appVersionEvaluationHandler := evaluation.NewHandler( - mgr.GetClient(), - appVersionEventSender, - appVersionLogger, - noop.NewTracerProvider().Tracer("keptn/lifecycle-operator/appversion"), - mgr.GetScheme(), - spanHandler, - ) + appVersionPhaseHandler := phase.NewHandler( mgr.GetClient(), appVersionEventSender, @@ -335,7 +318,6 @@ func main() { TracerFactory: telemetry.GetOtelInstance(), Meters: keptnMeters, SpanHandler: spanHandler, - EvaluationHandler: appVersionEvaluationHandler, PhaseHandler: appVersionPhaseHandler, PromotionTasksEnabled: env.PromotionTasksEnabled, Config: config.Instance(), diff --git a/lifecycle-operator/test/component/appversion/appversion_suite_test.go b/lifecycle-operator/test/component/appversion/appversion_suite_test.go index 3d2a8973be..ec78ada379 100644 --- a/lifecycle-operator/test/component/appversion/appversion_suite_test.go +++ b/lifecycle-operator/test/component/appversion/appversion_suite_test.go @@ -7,7 +7,6 @@ import ( "time" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/evaluation" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/phase" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/telemetry" @@ -44,13 +43,6 @@ var _ = BeforeSuite(func() { ctx, k8sManager, tracer, spanRecorder, k8sClient, readyToStart = common.InitSuite() tracerFactory := &common.TracerFactory{Tracer: tracer} - evaluationHandler := evaluation.NewHandler( - k8sManager.GetClient(), - eventsender.NewK8sSender(k8sManager.GetEventRecorderFor("test-appversion-controller")), - GinkgoLogr, - tracerFactory.GetTracer(traceComponentName), - k8sManager.GetScheme(), - &telemetry.Handler{}) phaseHandler := phase.NewHandler( k8sManager.GetClient(), @@ -63,16 +55,15 @@ var _ = BeforeSuite(func() { // //setup controllers here controller := &keptnappversion.KeptnAppVersionReconciler{ - Client: k8sManager.GetClient(), - Scheme: k8sManager.GetScheme(), - EventSender: eventsender.NewK8sSender(k8sManager.GetEventRecorderFor("test-appversion-controller")), - Log: GinkgoLogr, - Meters: common.InitKeptnMeters(), - SpanHandler: &telemetry.Handler{}, - TracerFactory: tracerFactory, - EvaluationHandler: evaluationHandler, - PhaseHandler: phaseHandler, - Config: config.Instance(), + Client: k8sManager.GetClient(), + Scheme: k8sManager.GetScheme(), + EventSender: eventsender.NewK8sSender(k8sManager.GetEventRecorderFor("test-appversion-controller")), + Log: GinkgoLogr, + Meters: common.InitKeptnMeters(), + SpanHandler: &telemetry.Handler{}, + TracerFactory: tracerFactory, + PhaseHandler: phaseHandler, + Config: config.Instance(), } Eventually(controller.SetupWithManager(k8sManager)).WithTimeout(30 * time.Second).WithPolling(time.Second).Should(Succeed()) close(readyToStart) diff --git a/lifecycle-operator/test/component/workloadversion/workloadversion_suite_test.go b/lifecycle-operator/test/component/workloadversion/workloadversion_suite_test.go index 5bedc38c0b..b5bc75ee6e 100644 --- a/lifecycle-operator/test/component/workloadversion/workloadversion_suite_test.go +++ b/lifecycle-operator/test/component/workloadversion/workloadversion_suite_test.go @@ -7,7 +7,6 @@ import ( "time" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/config" - "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/evaluation" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/eventsender" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/phase" "github.com/keptn/lifecycle-toolkit/lifecycle-operator/controllers/common/telemetry" @@ -46,13 +45,6 @@ var _ = BeforeSuite(func() { eventSender := eventsender.NewK8sSender(k8sManager.GetEventRecorderFor("test-workloadversion-controller")) tracerFactory := &common.TracerFactory{Tracer: tracer} - evaluationHandler := evaluation.NewHandler( - k8sManager.GetClient(), - eventSender, - GinkgoLogr, - tracerFactory.GetTracer(traceComponentName), - k8sManager.GetScheme(), - &telemetry.Handler{}) phaseHandler := phase.NewHandler( k8sManager.GetClient(), @@ -64,16 +56,15 @@ var _ = BeforeSuite(func() { // //setup controllers here config.Instance().SetDefaultNamespace(KeptnNamespace) controller := &keptnworkloadversion.KeptnWorkloadVersionReconciler{ - Client: k8sManager.GetClient(), - Scheme: k8sManager.GetScheme(), - EventSender: eventSender, - Log: GinkgoLogr, - Meters: common.InitKeptnMeters(), - SpanHandler: &telemetry.Handler{}, - TracerFactory: tracerFactory, - EvaluationHandler: evaluationHandler, - PhaseHandler: phaseHandler, - Config: config.Instance(), + Client: k8sManager.GetClient(), + Scheme: k8sManager.GetScheme(), + EventSender: eventSender, + Log: GinkgoLogr, + Meters: common.InitKeptnMeters(), + SpanHandler: &telemetry.Handler{}, + TracerFactory: tracerFactory, + PhaseHandler: phaseHandler, + Config: config.Instance(), } Eventually(controller.SetupWithManager(k8sManager)).WithTimeout(30 * time.Second).WithPolling(time.Second).Should(Succeed()) close(readyToStart)