Fix uninstall controller nil pointer issue
@@ -83,8 +83,14 @@ func NewUninstallController(
stopCh: stopCh,
}
- cacheSyncs := []cache.InformerSynced{}
- cacheSyncs = append(cacheSyncs, csiDriverInformer.Informer().HasSynced, daemonSetInformer.Informer().HasSynced, deploymentInformer.Informer().HasSynced)
+ csiDriverInformer.Informer().AddEventHandler(c.controlleeHandler())
+ daemonSetInformer.Informer().AddEventHandler(c.namespacedControlleeHandler())
+ deploymentInformer.Informer().AddEventHandler(c.namespacedControlleeHandler())
+ cacheSyncs := []cache.InformerSynced{
+ csiDriverInformer.Informer().HasSynced,
+ daemonSetInformer.Informer().HasSynced,
+ deploymentInformer.Informer().HasSynced,
+ }
if _, err := extensionsClient.ApiextensionsV1beta1().CustomResourceDefinitions().Get(CRDEngineName, metav1.GetOptions{}); err == nil {
engineInformer.Informer().AddEventHandler(c.controlleeHandler())
@@ -112,11 +118,6 @@ func NewUninstallController(
cacheSyncs = append(cacheSyncs, imInformer.Informer().HasSynced)
}
- csiDriverInformer.Informer().AddEventHandler(c.controlleeHandler())
-
- daemonSetInformer.Informer().AddEventHandler(c.namespacedControlleeHandler())
- deploymentInformer.Informer().AddEventHandler(c.namespacedControlleeHandler())
-
c.cacheSyncs = cacheSyncs
return c
@@ -145,13 +146,14 @@ func (c *UninstallController) enqueueControlleeChange() {
func (c *UninstallController) enqueueNamespacedControlleeChange(obj interface{}) {
metadata, err := meta.Accessor(obj)
if err != nil {
- utilruntime.HandleError(fmt.Errorf("Couldn't get meta for object %#v: %v", obj, err))
- }
- if metadata.GetNamespace() != LonghornNamespace {
+ utilruntime.HandleError(fmt.Errorf("couldn't get meta for object %#v: %v", obj, err))
return
}
+
+ if metadata.GetNamespace() == LonghornNamespace {
c.enqueueControlleeChange()
}
+}
func (c *UninstallController) Run() error {
defer utilruntime.HandleCrash()
