Skip to content

Commit

Permalink
Fix panic in spidercoordinator informer
Browse files Browse the repository at this point in the history
Signed-off-by: cyclinder <qifeng.guo@daocloud.io>
  • Loading branch information
cyclinder committed Mar 1, 2024
1 parent 3556e10 commit cde5d8e
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions pkg/coordinatormanager/coordinator_informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,18 @@ type CoordinatorController struct {
Client client.Client
APIReader client.Reader

CoordinatorLister spiderlisters.SpiderCoordinatorLister
ConfigmapLister corelister.ConfigMapLister
ServiceCIDRLister networkingLister.ServiceCIDRLister
CoordinatorLister spiderlisters.SpiderCoordinatorLister
ConfigmapLister corelister.ConfigMapLister
// only not to nil if the k8s serviceCIDR is enabled
ServiceCIDRLister networkingLister.ServiceCIDRLister
// only not to nil if the cilium multu-pool is enabled
CiliumIPPoolLister ciliumLister.CiliumPodIPPoolLister

CoordinatorSynced cache.InformerSynced
ConfigmapSynced cache.InformerSynced
ServiceCIDRSynced cache.InformerSynced
CoordinatorSynced cache.InformerSynced
ConfigmapSynced cache.InformerSynced
// only not nil if the k8s serviceCIDR is enabled
ServiceCIDRSynced cache.InformerSynced
// only not to nil if the cilium multu-pool is enabled
CiliumIPPoolsSynced cache.InformerSynced

Workqueue workqueue.RateLimitingInterface
Expand Down Expand Up @@ -505,7 +509,7 @@ func (cc *CoordinatorController) updatePodAndServerCIDR(ctx context.Context, log
}

if err = cc.updateServiceCIDR(logger, coordCopy); err != nil {
logger.Sugar().Warn("failed to list the serviceCIDR resources: %v, update service cidr from cluster service cidr", err)
logger.Sugar().Infof("failed to list the serviceCIDR resources: %v, update service cidr from cluster service cidr", err)
coordCopy.Status.ServiceCIDR = k8sServiceCIDR
}

Expand Down Expand Up @@ -706,6 +710,10 @@ func (cc *CoordinatorController) fetchCiliumIPPools(coordinator *spiderpoolv2bet

func (cc *CoordinatorController) updateServiceCIDR(logger *zap.Logger, coordCopy *spiderpoolv2beta1.SpiderCoordinator) error {
// fetch kubernetes ServiceCIDR
if cc.ServiceCIDRLister == nil {
return fmt.Errorf("the kubernetes serviceCIDR is disabled")
}

svcPoolList, err := cc.ServiceCIDRLister.List(labels.NewSelector())
if err != nil {
return err
Expand Down

0 comments on commit cde5d8e

Please sign in to comment.