fix an error when karmada-controller-manager restart

Signed-off-by: changzhen <changzhen5@huawei.com>
This commit is contained in:
changzhen 2021-09-26 20:38:50 +08:00
parent 08af87985a
commit e118c7909e
3 changed files with 7 additions and 12 deletions

View File

@ -285,11 +285,6 @@ func (c *ServiceExportController) handleEndpointSliceEvent(endpointSliceKey keys
return err
}
if endpointSliceObj == nil {
klog.V(2).Infof("Ignore the event key %s which not listened by karmada.", endpointSliceKey)
return nil
}
if err = c.reportEndpointSliceWithEndpointSliceCreateOrUpdate(endpointSliceKey.Cluster, endpointSliceObj); err != nil {
klog.Errorf("Failed to handle endpointSlice(%s) event, Error: %v",
endpointSliceKey.NamespaceKey(), err)

View File

@ -159,12 +159,6 @@ func (c *WorkStatusController) syncWorkStatus(key util.QueueKey) error {
return err
}
if obj == nil {
// Ignore the object which not managed by current karmada.
klog.V(2).Infof("Ignore the event key %s which not managed by karmada.", key)
return nil
}
workNamespace := util.GetLabelValue(obj.GetLabels(), workv1alpha1.WorkNamespaceLabel)
workName := util.GetLabelValue(obj.GetLabels(), workv1alpha1.WorkNameLabel)
if len(workNamespace) == 0 || len(workName) == 0 {

View File

@ -1,6 +1,8 @@
package helper
import (
"fmt"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@ -23,7 +25,11 @@ func GetObjectFromCache(restMapper meta.RESTMapper, manager informermanager.Mult
singleClusterManager := manager.GetSingleClusterManager(fedKey.Cluster)
if singleClusterManager == nil {
return nil, nil
// That may happen in case of multi-controllers sharing one informer. For example:
// controller-A takes responsibility of initialize informer for clusters, but controller-B consumes
// the informer before the initialization.
// Usually this error will be eliminated during the controller reconciling loop.
return nil, fmt.Errorf("the informer of cluster(%s) has not been initialized", fedKey.Cluster)
}
var obj runtime.Object
lister := singleClusterManager.Lister(gvr)