Skip to content

Commit

Permalink
chore: remove legacy kube-init and default to CNI state
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Baker <[email protected]>
  • Loading branch information
rbtr authored Jan 31, 2025
1 parent c670d53 commit c942654
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 154 deletions.
42 changes: 0 additions & 42 deletions cns/cnireconciler/version.go

This file was deleted.

76 changes: 0 additions & 76 deletions cns/cnireconciler/version_test.go

This file was deleted.

41 changes: 5 additions & 36 deletions cns/service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -836,25 +836,10 @@ func main() {
return
}

// We might be configured to reinitialize state from the CNI instead of the apiserver.
// If so, we should check that the CNI is new enough to support the state commands,
// otherwise we fall back to the existing behavior.
if cnsconfig.InitializeFromCNI {
var isGoodVer bool
isGoodVer, err = cnireconciler.IsDumpStateVer()
if err != nil {
logger.Errorf("error checking CNI ver: %v", err)
}

// override the prior config flag with the result of the ver check.
cnsconfig.InitializeFromCNI = isGoodVer

if cnsconfig.InitializeFromCNI {
// Set the PodInfoVersion by initialization type, so that the
// PodInfo maps use the correct key schema
cns.GlobalPodInfoScheme = cns.InterfaceIDPodInfoScheme
}
}
// By default reinitialize state from the CNI.
// Set the PodInfoVersion by initialization type, so that the
// PodInfo maps use the correct key schema
cns.GlobalPodInfoScheme = cns.InterfaceIDPodInfoScheme
// If cns manageendpointstate is true, then cns maintains its own state and reconciles from it.
// in this case, cns maintains state with containerid as key and so in-memory cache can lookup
// and update based on container id.
Expand Down Expand Up @@ -1675,29 +1660,13 @@ func getPodInfoByIPProvider(
return podInfoByIPProvider, errors.Wrap(err, "failed to create CNS PodInfoProvider")
}
}
case cnsconfig.InitializeFromCNI:
default:
logger.Printf("Initializing from CNI")
podInfoByIPProvider, err = cnireconciler.NewCNIPodInfoProvider()
if err != nil {
return podInfoByIPProvider, errors.Wrap(err, "failed to create CNI PodInfoProvider")
}
default:
logger.Printf("Initializing from Kubernetes")
podInfoByIPProvider = cns.PodInfoByIPProviderFunc(func() (map[string]cns.PodInfo, error) {
pods, err := clientset.CoreV1().Pods("").List(ctx, metav1.ListOptions{ //nolint:govet // ignore err shadow
FieldSelector: "spec.nodeName=" + nodeName,
})
if err != nil {
return nil, errors.Wrap(err, "failed to list Pods for PodInfoProvider")
}
podInfo, err := cns.KubePodsToPodInfoByIP(pods.Items)
if err != nil {
return nil, errors.Wrap(err, "failed to convert Pods to PodInfoByIP")
}
return podInfo, nil
})
}

return podInfoByIPProvider, nil
}

Expand Down

0 comments on commit c942654

Please sign in to comment.