diff --git a/pkg/cd/cd.go b/pkg/cd/cd.go index 4f633f41..b8297050 100644 --- a/pkg/cd/cd.go +++ b/pkg/cd/cd.go @@ -214,10 +214,13 @@ func (c *cd) GetResourceTree(ctx context.Context, var podDetail corev1.Pod err = c.informerFactories.GetDynamicFactory(params.RegionEntity.ID, func(factory dynamicinformer.DynamicSharedInformerFactory) error { + log.Debugf(ctx, "get pod detail: %v", node.Name) pods, err := gt.ListPods(&node, factory) if err != nil { + log.Debugf(ctx, "failed to get pod detail: %v", err) return err } + log.Debugf(ctx, "get pod detail success: %v", node.Name) podDetail = pods[0] return nil }) diff --git a/pkg/regioninformers/regioninformers.go b/pkg/regioninformers/regioninformers.go index f09084ec..ab04f798 100644 --- a/pkg/regioninformers/regioninformers.go +++ b/pkg/regioninformers/regioninformers.go @@ -68,6 +68,34 @@ type Target struct { Regions map[uint]struct{} } +type LoggingMutext struct { + sync.RWMutex +} + +func (m *LoggingMutext) Lock() { + log.Debugf(context.Background(), "Lock") + m.RWMutex.Lock() + log.Debugf(context.Background(), "Locked") +} + +func (m *LoggingMutext) Unlock() { + log.Debugf(context.Background(), "Unlock") + m.RWMutex.Unlock() + log.Debugf(context.Background(), "Unlocked") +} + +func (m *LoggingMutext) RLock() { + log.Debugf(context.Background(), "RLock") + m.RWMutex.RLock() + log.Debugf(context.Background(), "RLocked") +} + +func (m *LoggingMutext) RUnlock() { + log.Debugf(context.Background(), "RUnlock") + m.RWMutex.RUnlock() + log.Debugf(context.Background(), "RUnlocked") +} + // RegionInformers is a collection of informer factories for each region type RegionInformers struct { regionMgr manager.Manager @@ -77,7 +105,7 @@ type RegionInformers struct { handlers []Resource // mu protects factories, lastUpdated and stopChanMap - mu sync.RWMutex + mu LoggingMutext clients map[uint]*RegionClient } @@ -417,8 +445,10 @@ func (f *RegionInformers) GetDynamicFactory(regionID uint, operation DynamicFact return err } + log.Debugf(context.Background(), "get dynamic factory: %d", regionID) f.mu.RLock() defer f.mu.RUnlock() + log.Debugf(context.Background(), "got dynamic factory: %d", regionID) return operation(f.clients[regionID].dynamicFactory) }