@@ -836,25 +836,10 @@ func main() {
836836 return
837837 }
838838
839- // We might be configured to reinitialize state from the CNI instead of the apiserver.
840- // If so, we should check that the CNI is new enough to support the state commands,
841- // otherwise we fall back to the existing behavior.
842- if cnsconfig .InitializeFromCNI {
843- var isGoodVer bool
844- isGoodVer , err = cnireconciler .IsDumpStateVer ()
845- if err != nil {
846- logger .Errorf ("error checking CNI ver: %v" , err )
847- }
848-
849- // override the prior config flag with the result of the ver check.
850- cnsconfig .InitializeFromCNI = isGoodVer
851-
852- if cnsconfig .InitializeFromCNI {
853- // Set the PodInfoVersion by initialization type, so that the
854- // PodInfo maps use the correct key schema
855- cns .GlobalPodInfoScheme = cns .InterfaceIDPodInfoScheme
856- }
857- }
839+ // By default reinitialize state from the CNI.
840+ // Set the PodInfoVersion by initialization type, so that the
841+ // PodInfo maps use the correct key schema
842+ cns .GlobalPodInfoScheme = cns .InterfaceIDPodInfoScheme
858843 // If cns manageendpointstate is true, then cns maintains its own state and reconciles from it.
859844 // in this case, cns maintains state with containerid as key and so in-memory cache can lookup
860845 // and update based on container id.
@@ -1675,29 +1660,13 @@ func getPodInfoByIPProvider(
16751660 return podInfoByIPProvider , errors .Wrap (err , "failed to create CNS PodInfoProvider" )
16761661 }
16771662 }
1678- case cnsconfig . InitializeFromCNI :
1663+ default :
16791664 logger .Printf ("Initializing from CNI" )
16801665 podInfoByIPProvider , err = cnireconciler .NewCNIPodInfoProvider ()
16811666 if err != nil {
16821667 return podInfoByIPProvider , errors .Wrap (err , "failed to create CNI PodInfoProvider" )
16831668 }
1684- default :
1685- logger .Printf ("Initializing from Kubernetes" )
1686- podInfoByIPProvider = cns .PodInfoByIPProviderFunc (func () (map [string ]cns.PodInfo , error ) {
1687- pods , err := clientset .CoreV1 ().Pods ("" ).List (ctx , metav1.ListOptions { //nolint:govet // ignore err shadow
1688- FieldSelector : "spec.nodeName=" + nodeName ,
1689- })
1690- if err != nil {
1691- return nil , errors .Wrap (err , "failed to list Pods for PodInfoProvider" )
1692- }
1693- podInfo , err := cns .KubePodsToPodInfoByIP (pods .Items )
1694- if err != nil {
1695- return nil , errors .Wrap (err , "failed to convert Pods to PodInfoByIP" )
1696- }
1697- return podInfo , nil
1698- })
16991669 }
1700-
17011670 return podInfoByIPProvider , nil
17021671}
17031672
0 commit comments