mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Merge pull request #110372 from lokichoggio/topo
code optimization: deal with error first to prevent unnecessary computing
This commit is contained in:
		@@ -344,13 +344,6 @@ func (pl *PodTopologySpread) Filter(ctx context.Context, cycleState *framework.C
 | 
				
			|||||||
			return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonNodeLabelNotMatch)
 | 
								return framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonNodeLabelNotMatch)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		selfMatchNum := 0
 | 
					 | 
				
			||||||
		if c.Selector.Matches(podLabelSet) {
 | 
					 | 
				
			||||||
			selfMatchNum = 1
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		pair := topologyPair{key: tpKey, value: tpVal}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// judging criteria:
 | 
							// judging criteria:
 | 
				
			||||||
		// 'existing matching num' + 'if self-match (1 or 0)' - 'global minimum' <= 'maxSkew'
 | 
							// 'existing matching num' + 'if self-match (1 or 0)' - 'global minimum' <= 'maxSkew'
 | 
				
			||||||
		minMatchNum, err := s.minMatchNum(tpKey, c.MinDomains, pl.enableMinDomainsInPodTopologySpread)
 | 
							minMatchNum, err := s.minMatchNum(tpKey, c.MinDomains, pl.enableMinDomainsInPodTopologySpread)
 | 
				
			||||||
@@ -359,6 +352,12 @@ func (pl *PodTopologySpread) Filter(ctx context.Context, cycleState *framework.C
 | 
				
			|||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							selfMatchNum := 0
 | 
				
			||||||
 | 
							if c.Selector.Matches(podLabelSet) {
 | 
				
			||||||
 | 
								selfMatchNum = 1
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							pair := topologyPair{key: tpKey, value: tpVal}
 | 
				
			||||||
		matchNum := 0
 | 
							matchNum := 0
 | 
				
			||||||
		if tpCount, ok := s.TpPairToMatchNum[pair]; ok {
 | 
							if tpCount, ok := s.TpPairToMatchNum[pair]; ok {
 | 
				
			||||||
			matchNum = tpCount
 | 
								matchNum = tpCount
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user