Change:
/kind feature /sig scheduling Filter will return for all nodes when is and is . This can be done is PreFilter. Executing this code in the filter will cause it to be repeated tens of times, with the worst-case scenario being repeated thousands of times. Maybe we should move this to PreFilter like:
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the label and provide further guidance. The label can be by org members by writing in a comment. <detailsInstructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
Sounds reasonable to me :) I think you can go ahead and file a pr for this.
/assign
Sure.
Hi, If you don't mind, I can try to do this.
/assign

Discussion:
// PreFilter invoked at the prefilter extension point. func (f *Fit) PreFilter(ctx context.Context, cycleState *framework.CycleState, pod *v1.Pod) (*framework.PreFilterResult, *framework.Status) { <ins> if !f.enableSidecarContainers && hasRestartableInitContainer(pod) { // Scheduler will calculate resources usage for a Pod containing // restartable init containers that will be equal or more than kubelet will // require to run the Pod. So there will be no overbooking. However, to // avoid the inconsistency in resource calculation between the scheduler // and the older (before v1.28) kubelet, make the Pod unschedulable. return nil, framework.NewStatus(framework.UnschedulableAndUnresolvable, "Pod has a restartable init container and the SidecarContainers feature is disabled") } </ins> cycleState.Write(preFilterStateKey, computePodResourceRequest(pod)) return nil, nil }

// Checks if a node has sufficient resources, such as cpu, memory, gpu, opaque int resources etc to run a pod. // It returns a list of insufficient resources, if empty, then the node has all the resources requested by the pod. func (f *Fit) Filter(ctx context.Context, cycleState *framework.CycleState, pod *v1.Pod, nodeInfo *framework.NodeInfo) *framework.Status { <del> if !f.enableSidecarContainers && hasRestartableInitContainer(pod) { // Scheduler will calculate resources usage for a Pod containing // restartable init containers that will be equal or more than kubelet will // require to run the Pod. So there will be no overbooking. However, to // avoid the inconsistency in resource calculation between the scheduler // and the older (before v1.28) kubelet, make the Pod unschedulable. return framework.NewStatus(framework.UnschedulableAndUnresolvable, "Pod has a restartable init container and the SidecarContainers feature is disabled") } </del> s, err := getPreFilterState(cycleState) if err != nil { return framework.AsStatus(err)

name                    string pod                     *v1.Pod enableSidecarContainers bool <del> wantStatus              *framework.Status </del> <ins> wantPreFilterStatus     *framework.Status </ins> }{ { name: "allow pod without restartable init containers if sidecar containers is disabled", pod:  newPod(), }, { <del> name:       "not allow pod with restartable init containers if sidecar containers is disabled", pod:        newPodWithRestartableInitContainers(), wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, "Pod has a restartable init container and the SidecarContainers feature is disabled"), </del> <ins> name:                "not allow pod with restartable init containers if sidecar containers is disabled", pod:                 newPodWithRestartableInitContainers(), wantPreFilterStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, "Pod has a restartable init container and the SidecarContainers feature is disabled"), </ins> }, { name:                    "allow pod without restartable init containers if sidecar containers is enabled",

} cycleState := framework.NewCycleState() _, preFilterStatus := p.(framework.PreFilterPlugin).PreFilter(context.Background(), cycleState, test.pod) <ins> if diff := cmp.Diff(test.wantPreFilterStatus, preFilterStatus); diff != "" { t.Error("status does not match (-expected +actual):n", diff) } </ins> if !preFilterStatus.IsSuccess() { <del> t.Errorf("prefilter failed with status: %v", preFilterStatus) </del> <ins> return </ins> } <del> gotStatus := p.(framework.FilterPlugin).Filter(context.Background(), cycleState, test.pod, nodeInfo) if diff := cmp.Diff(gotStatus, test.wantStatus); diff != "" { t.Errorf("status does not match: %v, want: %v", gotStatus, test.wantStatus) </del> <ins> filterStatus := p.(framework.FilterPlugin).Filter(ctx, cycleState, test.pod, nodeInfo) if !filterStatus.IsSuccess() { t.Error("status does not match (-expected +actual):n- Successn +n", filterStatus.Code()) </ins> } }) }