@@ -841,25 +841,10 @@ func main() {
841841 return
842842 }
843843
844- // We might be configured to reinitialize state from the CNI instead of the apiserver.
845- // If so, we should check that the CNI is new enough to support the state commands,
846- // otherwise we fall back to the existing behavior.
847- if cnsconfig .InitializeFromCNI {
848- var isGoodVer bool
849- isGoodVer , err = cnireconciler .IsDumpStateVer ()
850- if err != nil {
851- logger .Errorf ("error checking CNI ver: %v" , err )
852- }
853-
854- // override the prior config flag with the result of the ver check.
855- cnsconfig .InitializeFromCNI = isGoodVer
856-
857- if cnsconfig .InitializeFromCNI {
858- // Set the PodInfoVersion by initialization type, so that the
859- // PodInfo maps use the correct key schema
860- cns .GlobalPodInfoScheme = cns .InterfaceIDPodInfoScheme
861- }
862- }
844+ // By default reinitialize state from the CNI.
845+ // Set the PodInfoVersion by initialization type, so that the
846+ // PodInfo maps use the correct key schema
847+ cns .GlobalPodInfoScheme = cns .InterfaceIDPodInfoScheme
863848 // If cns manageendpointstate is true, then cns maintains its own state and reconciles from it.
864849 // in this case, cns maintains state with containerid as key and so in-memory cache can lookup
865850 // and update based on container id.
@@ -1680,29 +1665,13 @@ func getPodInfoByIPProvider(
16801665 return podInfoByIPProvider , errors .Wrap (err , "failed to create CNS PodInfoProvider" )
16811666 }
16821667 }
1683- case cnsconfig . InitializeFromCNI :
1668+ default :
16841669 logger .Printf ("Initializing from CNI" )
16851670 podInfoByIPProvider , err = cnireconciler .NewCNIPodInfoProvider ()
16861671 if err != nil {
16871672 return podInfoByIPProvider , errors .Wrap (err , "failed to create CNI PodInfoProvider" )
16881673 }
1689- default :
1690- logger .Printf ("Initializing from Kubernetes" )
1691- podInfoByIPProvider = cns .PodInfoByIPProviderFunc (func () (map [string ]cns.PodInfo , error ) {
1692- pods , err := clientset .CoreV1 ().Pods ("" ).List (ctx , metav1.ListOptions { //nolint:govet // ignore err shadow
1693- FieldSelector : "spec.nodeName=" + nodeName ,
1694- })
1695- if err != nil {
1696- return nil , errors .Wrap (err , "failed to list Pods for PodInfoProvider" )
1697- }
1698- podInfo , err := cns .KubePodsToPodInfoByIP (pods .Items )
1699- if err != nil {
1700- return nil , errors .Wrap (err , "failed to convert Pods to PodInfoByIP" )
1701- }
1702- return podInfo , nil
1703- })
17041674 }
1705-
17061675 return podInfoByIPProvider , nil
17071676}
17081677
0 commit comments