Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove legacy kube-init and default to CNI state #3383

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading