Skip to content

Commit

Permalink
fix(lifecycle-operator): remove noops tracer for evaluations (#3290)
Browse files Browse the repository at this point in the history
Signed-off-by: RealAnna <[email protected]>
  • Loading branch information
RealAnna authored Mar 19, 2024
1 parent 0735e31 commit 4948dc5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
40 changes: 11 additions & 29 deletions lifecycle-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -279,31 +277,23 @@ 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,
workloadVersionLogger,
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")
Expand All @@ -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,
Expand All @@ -335,7 +318,6 @@ func main() {
TracerFactory: telemetry.GetOtelInstance(),
Meters: keptnMeters,
SpanHandler: spanHandler,
EvaluationHandler: appVersionEvaluationHandler,
PhaseHandler: appVersionPhaseHandler,
PromotionTasksEnabled: env.PromotionTasksEnabled,
Config: config.Instance(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(),
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(),
Expand All @@ -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)
Expand Down

0 comments on commit 4948dc5

Please sign in to comment.