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

[cherry-pick for release-1.8]fix: the pod anti-affinity constraint fails #3140

Merged
Merged
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
4 changes: 2 additions & 2 deletions pkg/scheduler/api/devices/nvidia/vgpu/device_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@ func (gs *GPUDevices) Release(kubeClient kubernetes.Interface, pod *v1.Pod) erro
}

func (gs *GPUDevices) FilterNode(pod *v1.Pod) (int, string, error) {
klog.V(3).Infoln("4pdvgpuDeviceSharing:Into FitInPod", pod.Name)
klog.V(5).Infoln("4pdvgpu DeviceSharing starts filtering pods", pod.Name)
if VGPUEnable {
fit, _, err := checkNodeGPUSharingPredicate(pod, gs, true)
if err != nil || !fit {
klog.Errorln("deviceSharing err=", err.Error())
return devices.Unschedulable, fmt.Sprintf("4pdvgpuDeviceSharing %s", err.Error()), err
}
}
klog.V(3).Infoln("4pdvgpu DeviceSharing:FitInPod successed")
klog.V(5).Infoln("4pdvgpu DeviceSharing successfully filters pods")
return devices.Success, "", nil
}

Expand Down
23 changes: 19 additions & 4 deletions pkg/scheduler/plugins/predicates/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@ func (pp *predicatesPlugin) OnSessionOpen(ssn *framework.Session) {
podTopologySpreadFilter := plugin.(*podtopologyspread.PodTopologySpread)

state := k8sframework.NewCycleState()
skipPlugins := sets.New[string]()
state.SkipFilterPlugins = skipPlugins
skipPlugins := make(map[api.TaskID]sets.Set[string])

ssn.AddPrePredicateFn(pp.Name(), func(task *api.TaskInfo) error {
// Check NodePorts
Expand All @@ -376,7 +375,14 @@ func (pp *predicatesPlugin) OnSessionOpen(ssn *framework.Session) {
if predicate.podAffinityEnable {
_, status := podAffinityFilter.PreFilter(context.TODO(), state, task.Pod)
if status.IsSkip() {
state.SkipFilterPlugins.Insert(interpodaffinity.Name)
taskKey := api.PodKey(task.Pod)
if _, ok := skipPlugins[taskKey]; !ok {
plugins := sets.New[string]()
skipPlugins[taskKey] = plugins
}
skipPlugins[taskKey].Insert(interpodaffinity.Name)
klog.V(3).Infof("pod(%s/%s) affinity require information is nil, plugin InterPodAffinity is skipped",
task.Namespace, task.Name)
} else if !status.IsSuccess() {
return fmt.Errorf("plugin %s pre-predicates failed %s", interpodaffinity.Name, status.Message())
}
Expand Down Expand Up @@ -491,7 +497,16 @@ func (pp *predicatesPlugin) OnSessionOpen(ssn *framework.Session) {

// Check PodAffinity
if predicate.podAffinityEnable {
if !state.SkipFilterPlugins.Has(interpodaffinity.Name) {
isSkipInterPodAffinity := false
taskKey := api.PodKey(task.Pod)
if plugins, ok := skipPlugins[taskKey]; ok {
if plugins.Has(interpodaffinity.Name) {
isSkipInterPodAffinity = true
klog.V(5).Infof("pod(%s/%s) affinity require information is nil, plugin InterPodAffinity is skip for node %s",
task.Namespace, task.Name, node.Name)
}
}
if !isSkipInterPodAffinity {
status := podAffinityFilter.Filter(context.TODO(), state, task.Pod, nodeInfo)
podAffinityStatus := framework.ConvertPredicateStatus(status)
if podAffinityStatus.Code != api.Success {
Expand Down
Loading