@@ -280,8 +280,14 @@ func (npc *NetworkPolicyController) syncNetworkPolicyChains() (map[string]bool,
280280 currnetPodIps = append (currnetPodIps , ip )
281281 }
282282
283- targetSourcePodIpSet .Refresh (currnetPodIps , utils .OptionTimeout , "0" )
284- targetDestPodIpSet .Refresh (currnetPodIps , utils .OptionTimeout , "0" )
283+ err = targetSourcePodIpSet .Refresh (currnetPodIps , utils .OptionTimeout , "0" )
284+ if err != nil {
285+ glog .Errorf ("failed to refresh targetSourcePodIpSet: " + err .Error ())
286+ }
287+ err = targetDestPodIpSet .Refresh (currnetPodIps , utils .OptionTimeout , "0" )
288+ if err != nil {
289+ glog .Errorf ("failed to refresh targetDestPodIpSet: " + err .Error ())
290+ }
285291
286292 // TODO use iptables-restore to better implement the logic, than flush and add rules
287293 err = iptablesCmdHandler .ClearChain ("filter" , policyChainName )
@@ -338,7 +344,10 @@ func (npc *NetworkPolicyController) processIngressRules(policy networkPolicyInfo
338344 for _ , pod := range ingressRule .srcPods {
339345 ingressRuleSrcPodIps = append (ingressRuleSrcPodIps , pod .ip )
340346 }
341- srcPodIpSet .Refresh (ingressRuleSrcPodIps , utils .OptionTimeout , "0" )
347+ err = srcPodIpSet .Refresh (ingressRuleSrcPodIps , utils .OptionTimeout , "0" )
348+ if err != nil {
349+ glog .Errorf ("failed to refresh srcPodIpSet: " + err .Error ())
350+ }
342351
343352 if len (ingressRule .ports ) != 0 {
344353 // case where 'ports' details and 'from' details specified in the ingress rule
@@ -1047,6 +1056,9 @@ func (npc *NetworkPolicyController) buildNetworkPoliciesInfo() (*[]networkPolicy
10471056 newPolicy .targetPods = make (map [string ]podInfo )
10481057 if err == nil {
10491058 for _ , matchingPod := range matchingPods {
1059+ if matchingPod .Status .PodIP == "" {
1060+ continue
1061+ }
10501062 newPolicy .targetPods [matchingPod .Status .PodIP ] = podInfo {ip : matchingPod .Status .PodIP ,
10511063 name : matchingPod .ObjectMeta .Name ,
10521064 namespace : matchingPod .ObjectMeta .Namespace ,
@@ -1114,6 +1126,9 @@ func (npc *NetworkPolicyController) buildNetworkPoliciesInfo() (*[]networkPolicy
11141126 }
11151127 if err == nil {
11161128 for _ , matchingPod := range matchingPods {
1129+ if matchingPod .Status .PodIP == "" {
1130+ continue
1131+ }
11171132 ingressRule .srcPods = append (ingressRule .srcPods ,
11181133 podInfo {ip : matchingPod .Status .PodIP ,
11191134 name : matchingPod .ObjectMeta .Name ,
@@ -1228,6 +1243,9 @@ func (npc *NetworkPolicyController) buildBetaNetworkPoliciesInfo() (*[]networkPo
12281243 newPolicy .ingressRules = make ([]ingressRule , 0 )
12291244 if err == nil {
12301245 for _ , matchingPod := range matchingPods {
1246+ if matchingPod .Status .PodIP == "" {
1247+ continue
1248+ }
12311249 newPolicy .targetPods [matchingPod .Status .PodIP ] = podInfo {ip : matchingPod .Status .PodIP ,
12321250 name : matchingPod .ObjectMeta .Name ,
12331251 namespace : matchingPod .ObjectMeta .Namespace ,
@@ -1249,6 +1267,9 @@ func (npc *NetworkPolicyController) buildBetaNetworkPoliciesInfo() (*[]networkPo
12491267 matchingPods , err := npc .ListPodsByNamespaceAndLabels (policy .Namespace , peer .PodSelector .MatchLabels )
12501268 if err == nil {
12511269 for _ , matchingPod := range matchingPods {
1270+ if matchingPod .Status .PodIP == "" {
1271+ continue
1272+ }
12521273 ingressRule .srcPods = append (ingressRule .srcPods ,
12531274 podInfo {ip : matchingPod .Status .PodIP ,
12541275 name : matchingPod .ObjectMeta .Name ,
0 commit comments