@@ -160,7 +160,7 @@ func (nrc *NetworkRoutingController) Run(healthChan chan<- *healthcheck.Controll
160160 }
161161
162162 klog .V (1 ).Info ("Populating ipsets." )
163- err = nrc .syncNodeIPSets (nrc . krNode )
163+ err = nrc .syncNodeIPSets ()
164164 if err != nil {
165165 klog .Errorf ("Failed initial ipset setup: %s" , err )
166166 }
@@ -353,7 +353,7 @@ func (nrc *NetworkRoutingController) Run(healthChan chan<- *healthcheck.Controll
353353 // Update ipset entries
354354 if nrc .enablePodEgress || nrc .enableOverlays {
355355 klog .V (1 ).Info ("Syncing ipsets" )
356- err = nrc .syncNodeIPSets (nrc . krNode )
356+ err = nrc .syncNodeIPSets ()
357357 if err != nil {
358358 klog .Errorf ("Error synchronizing ipsets: %s" , err .Error ())
359359 }
@@ -788,7 +788,7 @@ func (nrc *NetworkRoutingController) Cleanup() {
788788 klog .Infof ("Successfully cleaned the NetworkRoutesController configuration done by kube-router" )
789789}
790790
791- func (nrc * NetworkRoutingController ) syncNodeIPSets (nodeIPAware utils. NodeIPAware ) error {
791+ func (nrc * NetworkRoutingController ) syncNodeIPSets () error {
792792 var err error
793793 start := time .Now ()
794794 defer func () {
@@ -810,16 +810,16 @@ func (nrc *NetworkRoutingController) syncNodeIPSets(nodeIPAware utils.NodeIPAwar
810810 currentPodCidrs := make (map [v1core.IPFamily ][][]string )
811811 currentNodeIPs := make (map [v1core.IPFamily ][][]string )
812812 for _ , obj := range nodes {
813- node := obj .(* v1core.Node )
814- podCIDRs := getPodCIDRsFromAllNodeSources (node )
813+ n := obj .(* v1core.Node )
814+ podCIDRs := getPodCIDRsFromAllNodeSources (n )
815815 if len (podCIDRs ) < 1 {
816- klog .Warningf ("Couldn't determine any Pod CIDRs for the %v node, skipping" , node .Name )
816+ klog .Warningf ("Couldn't determine any Pod CIDRs for the %v node, skipping" , n .Name )
817817 continue
818818 }
819819 for _ , cidr := range podCIDRs {
820820 ip , _ , err := net .ParseCIDR (cidr )
821821 if err != nil {
822- klog .Warningf ("Wasn't able to parse pod CIDR %s for node %s, skipping" , cidr , node .Name )
822+ klog .Warningf ("Wasn't able to parse pod CIDR %s for node %s, skipping" , cidr , n .Name )
823823 }
824824 if ip .To4 () != nil {
825825 currentPodCidrs [v1core .IPv4Protocol ] = append (currentPodCidrs [v1core .IPv4Protocol ],
@@ -831,10 +831,15 @@ func (nrc *NetworkRoutingController) syncNodeIPSets(nodeIPAware utils.NodeIPAwar
831831 }
832832
833833 var ipv4Addrs , ipv6Addrs [][]string
834- for _ , nodeIPv4 := range nodeIPAware .GetNodeIPv4Addrs () {
834+ nrk , err := utils .NewRemoteKRNode (n )
835+ if err != nil {
836+ klog .Errorf ("failed to create remote node object for node %s: %v" , n .Name , err )
837+ continue
838+ }
839+ for _ , nodeIPv4 := range nrk .GetNodeIPv4Addrs () {
835840 ipv4Addrs = append (ipv4Addrs , []string {nodeIPv4 .String (), utils .OptionTimeout , "0" })
836841 }
837- for _ , nodeIPv6 := range nodeIPAware .GetNodeIPv6Addrs () {
842+ for _ , nodeIPv6 := range nrk .GetNodeIPv6Addrs () {
838843 ipv6Addrs = append (ipv6Addrs , []string {nodeIPv6 .String (), utils .OptionTimeout , "0" })
839844 }
840845 currentNodeIPs [v1core .IPv4Protocol ] = append (currentNodeIPs [v1core .IPv4Protocol ], ipv4Addrs ... )
0 commit comments