Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic in spidercoordinator informer #3269

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 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("unable 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,11 @@ func (cc *CoordinatorController) fetchCiliumIPPools(coordinator *spiderpoolv2bet

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

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