From f32f03162ef723da5d12fa8f4c822157d25ba4e0 Mon Sep 17 00:00:00 2001 From: talsabagport Date: Wed, 24 May 2023 13:20:54 +0300 Subject: [PATCH] Ignore non existent kinds --- pkg/handlers/controllers.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/handlers/controllers.go b/pkg/handlers/controllers.go index f5d0f33..08f080f 100644 --- a/pkg/handlers/controllers.go +++ b/pkg/handlers/controllers.go @@ -28,7 +28,8 @@ func NewControllersHandler(exporterConfig *config.Config, k8sClient *k8s.Client, var gvr schema.GroupVersionResource gvr, err := k8s.GetGVRFromResource(k8sClient.DiscoveryMapper, resource.Kind) if err != nil { - klog.Fatalf("Error getting GVR for resource '%s': %s", resource.Kind, err.Error()) + klog.Errorf("Error getting GVR, skip handling for resource '%s': %s.", resource.Kind, err.Error()) + continue } informer := informersFactory.ForResource(gvr) @@ -36,6 +37,10 @@ func NewControllersHandler(exporterConfig *config.Config, k8sClient *k8s.Client, controllers = append(controllers, controller) } + if len(controllers) == 0 { + klog.Fatalf("Failed to initiate a controller for all resources, exiting...") + } + controllersHandler := &ControllersHandler{ controllers: controllers, informersFactory: informersFactory,