@@ -29,7 +29,7 @@ func NewReconcilerClient(kubeClient kubernetes.Interface, apiServerClient client
29
29
}
30
30
31
31
// Initialize informers
32
- informerInitHandlerMap := map [k8s.InformerKey ]func (){
32
+ informerInitHandlerMap := map [k8s.InformerKey ]func () error {
33
33
CrdInformerKey : c .initCustomResourceDefinitionMonitor ,
34
34
MutatingWebhookInformerKey : c .initMutatingWebhookConfigurationMonitor ,
35
35
ValidatingWebhookInformerKey : c .initValidatingWebhookConfigurationMonitor ,
@@ -46,7 +46,10 @@ func NewReconcilerClient(kubeClient kubernetes.Interface, apiServerClient client
46
46
}
47
47
48
48
for _ , informer := range selectInformers {
49
- informerInitHandlerMap [informer ]()
49
+ if err := informerInitHandlerMap [informer ](); err != nil {
50
+ log .Error ().Err (err ).Msgf ("Error initializing informer %s" , informer )
51
+ return err
52
+ }
50
53
}
51
54
52
55
if err := c .run (stop ); err != nil {
@@ -59,7 +62,7 @@ func NewReconcilerClient(kubeClient kubernetes.Interface, apiServerClient client
59
62
}
60
63
61
64
// Initializes CustomResourceDefinition monitoring
62
- func (c * client ) initCustomResourceDefinitionMonitor () {
65
+ func (c * client ) initCustomResourceDefinitionMonitor () error {
63
66
// Use the OSM version as the selector for reconciliation
64
67
osmCrdsLabel := map [string ]string {constants .OSMAppNameLabelKey : constants .OSMAppNameLabelValue , constants .ReconcileLabel : c .osmVersion }
65
68
@@ -74,11 +77,15 @@ func (c *client) initCustomResourceDefinitionMonitor() {
74
77
c .informers [CrdInformerKey ] = informerFactory
75
78
76
79
// Add event handler to informer
77
- c .informers [CrdInformerKey ].AddEventHandler (c .crdEventHandler ())
80
+ if _ , err := c .informers [CrdInformerKey ].AddEventHandler (c .crdEventHandler ()); err != nil {
81
+ log .Error ().Err (err ).Msgf ("Error adding event handler to informer %s" , CrdInformerKey )
82
+ return err
83
+ }
84
+ return nil
78
85
}
79
86
80
87
// Initializes mutating webhook monitoring
81
- func (c * client ) initMutatingWebhookConfigurationMonitor () {
88
+ func (c * client ) initMutatingWebhookConfigurationMonitor () error {
82
89
osmMwhcLabel := map [string ]string {constants .OSMAppNameLabelKey : constants .OSMAppNameLabelValue , constants .OSMAppInstanceLabelKey : c .meshName , constants .ReconcileLabel : strconv .FormatBool (true )}
83
90
labelSelector := fields .SelectorFromSet (osmMwhcLabel ).String ()
84
91
option := informers .WithTweakListOptions (func (opt * metav1.ListOptions ) {
@@ -91,11 +98,15 @@ func (c *client) initMutatingWebhookConfigurationMonitor() {
91
98
c .informers [MutatingWebhookInformerKey ] = informerFactory .Admissionregistration ().V1 ().MutatingWebhookConfigurations ().Informer ()
92
99
93
100
// Add event handler to informer
94
- c .informers [MutatingWebhookInformerKey ].AddEventHandler (c .mutatingWebhookEventHandler ())
101
+ if _ , err := c .informers [MutatingWebhookInformerKey ].AddEventHandler (c .mutatingWebhookEventHandler ()); err != nil {
102
+ log .Error ().Err (err ).Msgf ("Error adding event handler to informer %s" , MutatingWebhookInformerKey )
103
+ return err
104
+ }
105
+ return nil
95
106
}
96
107
97
108
// Initializes validating webhook monitoring
98
- func (c * client ) initValidatingWebhookConfigurationMonitor () {
109
+ func (c * client ) initValidatingWebhookConfigurationMonitor () error {
99
110
osmVwhcLabel := map [string ]string {constants .OSMAppNameLabelKey : constants .OSMAppNameLabelValue , constants .OSMAppInstanceLabelKey : c .meshName , constants .ReconcileLabel : strconv .FormatBool (true )}
100
111
labelSelector := fields .SelectorFromSet (osmVwhcLabel ).String ()
101
112
option := informers .WithTweakListOptions (func (opt * metav1.ListOptions ) {
@@ -108,7 +119,10 @@ func (c *client) initValidatingWebhookConfigurationMonitor() {
108
119
c .informers [ValidatingWebhookInformerKey ] = informerFactory .Admissionregistration ().V1 ().ValidatingWebhookConfigurations ().Informer ()
109
120
110
121
// Add event handler to informer
111
- c .informers [ValidatingWebhookInformerKey ].AddEventHandler (c .validatingWebhookEventHandler ())
122
+ if _ , err := c .informers [ValidatingWebhookInformerKey ].AddEventHandler (c .validatingWebhookEventHandler ()); err != nil {
123
+ log .Error ().Err (err ).Msgf ("Error adding event handler to informer %s" , ValidatingWebhookInformerKey )
124
+ }
125
+ return nil
112
126
}
113
127
114
128
func (c * client ) run (stop <- chan struct {}) error {
0 commit comments