@@ -978,16 +978,18 @@ func (s *ServiceAffinity) serviceAffinityMetadataProducer(pm *predicateMetadata)
978
978
return
979
979
}
980
980
pm .serviceAffinityInUse = true
981
- var errSvc , errList error
981
+ var err error
982
982
// Store services which match the pod.
983
- pm .serviceAffinityMatchingPodServices , errSvc = s .serviceLister .GetPodServices (pm .pod )
983
+ pm .serviceAffinityMatchingPodServices , err = s .serviceLister .GetPodServices (pm .pod )
984
+ if err != nil {
985
+ klog .Errorf ("Error precomputing service affinity: could not list services: %v" , err )
986
+ }
984
987
selector := CreateSelectorFromLabels (pm .pod .Labels )
985
- allMatches , errList := s .podLister .List (selector )
986
-
987
- // In the future maybe we will return them as part of the function.
988
- if errSvc != nil || errList != nil {
989
- klog .Errorf ("Some Error were found while precomputing svc affinity: \n services:%v , \n pods:%v" , errSvc , errList )
988
+ allMatches , err := s .podLister .List (selector )
989
+ if err != nil {
990
+ klog .Errorf ("Error precomputing service affinity: could not list pods: %v" , err )
990
991
}
992
+
991
993
// consider only the pods that belong to the same namespace
992
994
pm .serviceAffinityMatchingPodList = FilterPodsByNamespace (allMatches , pm .pod .Namespace )
993
995
}
@@ -1315,7 +1317,8 @@ func (c *PodAffinityChecker) getMatchingAntiAffinityTopologyPairsOfPods(pod *v1.
1315
1317
existingPodNode , err := c .info .GetNodeInfo (existingPod .Spec .NodeName )
1316
1318
if err != nil {
1317
1319
if apierrors .IsNotFound (err ) {
1318
- klog .Errorf ("Node not found, %v" , existingPod .Spec .NodeName )
1320
+ klog .Errorf ("Pod %s has NodeName %q but node is not found" ,
1321
+ podName (existingPod ), existingPod .Spec .NodeName )
1319
1322
continue
1320
1323
}
1321
1324
return nil , err
@@ -1344,12 +1347,12 @@ func (c *PodAffinityChecker) satisfiesExistingPodsAntiAffinity(pod *v1.Pod, meta
1344
1347
// present in nodeInfo. Pods on other nodes pass the filter.
1345
1348
filteredPods , err := c .podLister .FilteredList (nodeInfo .Filter , labels .Everything ())
1346
1349
if err != nil {
1347
- errMessage := fmt .Sprintf ("Failed to get all pods, %+ v" , err )
1350
+ errMessage := fmt .Sprintf ("Failed to get all pods: % v" , err )
1348
1351
klog .Error (errMessage )
1349
1352
return ErrExistingPodsAntiAffinityRulesNotMatch , errors .New (errMessage )
1350
1353
}
1351
1354
if topologyMaps , err = c .getMatchingAntiAffinityTopologyPairsOfPods (pod , filteredPods ); err != nil {
1352
- errMessage := fmt .Sprintf ("Failed to get all terms that pod %+v matches, err : %+ v" , podName (pod ), err )
1355
+ errMessage := fmt .Sprintf ("Failed to get all terms that match pod %s : %v" , podName (pod ), err )
1353
1356
klog .Error (errMessage )
1354
1357
return ErrExistingPodsAntiAffinityRulesNotMatch , errors .New (errMessage )
1355
1358
}
@@ -1454,7 +1457,7 @@ func (c *PodAffinityChecker) satisfiesPodsAffinityAntiAffinity(pod *v1.Pod,
1454
1457
if ! matchFound && len (affinityTerms ) > 0 {
1455
1458
affTermsMatch , termsSelectorMatch , err := c .podMatchesPodAffinityTerms (pod , targetPod , nodeInfo , affinityTerms )
1456
1459
if err != nil {
1457
- errMessage := fmt .Sprintf ("Cannot schedule pod %+v onto node %v , because of PodAffinity, err : %v" , podName (pod ), node .Name , err )
1460
+ errMessage := fmt .Sprintf ("Cannot schedule pod %s onto node %s , because of PodAffinity: %v" , podName (pod ), node .Name , err )
1458
1461
klog .Error (errMessage )
1459
1462
return ErrPodAffinityRulesNotMatch , errors .New (errMessage )
1460
1463
}
0 commit comments