File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 88 "slices"
99 "strings"
1010
11- openreportsv1alpha1 "github.com/openreports/reports-api/apis/openreports.io/v1alpha1"
1211 batchv1 "k8s.io/api/batch/v1"
1312 corev1 "k8s.io/api/core/v1"
1413 eventsv1 "k8s.io/api/events/v1"
@@ -66,8 +65,7 @@ func (r *ScanJobReconciler) SetupWithManager(mgr ctrl.Manager) error {
6665 inNamespacePredicate (r .ScanJobNamespace ),
6766 jobIsFinished ,
6867 ignoreDeletionPredicate (),
69- )).
70- Watches (& openreportsv1alpha1.Report {}, handler.Funcs {}). // Watches reports with empty handler to ensure informer creation for metrics collection
68+ )).
7169 Complete (r .reconcile ())
7270 if err != nil {
7371 return err
Original file line number Diff line number Diff line change @@ -262,6 +262,14 @@ func (o Operator) Start(cfg config.Config) error {
262262 return fmt .Errorf ("unable to set up ready check: %w" , err )
263263 }
264264
265+ ctx := ctrl .SetupSignalHandler ()
266+
267+ // We need to create an informer for reports to ensure all reports are available in cache to
268+ // serve custom image scanner metrics.
269+ if _ , err := mgr .GetCache ().GetInformer (ctx , & openreportsv1alpha1.Report {}); err != nil {
270+ return fmt .Errorf ("failed to create reports informer: %w" , err )
271+ }
272+
265273 if err = (& metrics.ImageMetricsCollector {
266274 Reader : mgr .GetCache (),
267275 Config : cfg ,
@@ -272,7 +280,7 @@ func (o Operator) Start(cfg config.Config) error {
272280
273281 ctrl .Log .Info ("starting manager" )
274282
275- if err := mgr .Start (ctrl . SetupSignalHandler () ); err != nil {
283+ if err := mgr .Start (ctx ); err != nil {
276284 return fmt .Errorf ("problem running manager: %w" , err )
277285 }
278286
You can’t perform that action at this time.
0 commit comments