@@ -31,6 +31,7 @@ import (
31
31
v1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
32
32
"github.com/prometheus/client_golang/prometheus"
33
33
corev1 "k8s.io/api/core/v1"
34
+ "k8s.io/apimachinery/pkg/runtime/schema"
34
35
"k8s.io/apimachinery/pkg/types"
35
36
"k8s.io/client-go/tools/record"
36
37
ctrl "sigs.k8s.io/controller-runtime"
@@ -542,6 +543,38 @@ func SetupLoggingWithManager(mgr ctrl.Manager, logger logr.Logger) *ctrl.Builder
542
543
return nil
543
544
}
544
545
546
+ for _ , ref := range obj .GetOwnerReferences () {
547
+ refGV , err := schema .ParseGroupVersion (ref .APIVersion )
548
+ if err != nil {
549
+ logger .Error (err , "failed to parse group version" , "apiVersion" , ref .APIVersion )
550
+ continue
551
+ }
552
+
553
+ const (
554
+ FluentbitAgentKind = "FluentbitAgent"
555
+ FluentdConfigKind = "FluentdConfig"
556
+ SyslogNGConfigKind = "SyslogNGConfig"
557
+ )
558
+
559
+ // Check if this is owned by FluentbitAgent, FluentdConfig, or SyslogNGConfig
560
+ // and then map back to the relevant Logging resource
561
+ if refGV .Group == loggingv1beta1 .GroupVersion .Group {
562
+ switch ref .Kind {
563
+ case FluentbitAgentKind :
564
+ var agent loggingv1beta1.FluentbitAgent
565
+ if err := mgr .GetClient ().Get (ctx , types.NamespacedName {
566
+ Name : ref .Name ,
567
+ Namespace : obj .GetNamespace (),
568
+ }, & agent ); err == nil {
569
+ return reconcileRequestsForLoggingRef (loggingList .Items , agent .Spec .LoggingRef )
570
+ }
571
+
572
+ case FluentdConfigKind , SyslogNGConfigKind :
573
+ return reconcileRequestsForMatchingControlNamespace (loggingList .Items , obj .GetNamespace ())
574
+ }
575
+ }
576
+ }
577
+
545
578
switch o := obj .(type ) {
546
579
case * loggingv1beta1.ClusterOutput :
547
580
return reconcileRequestsForLoggingRef (loggingList .Items , o .Spec .LoggingRef )
0 commit comments