changes in non-test files

This commit is contained in:
kidddddddddddddddddddddd 2022-09-05 12:43:45 +08:00
parent 1eb9d42c3f
commit 121d24cfc7
4 changed files with 11 additions and 8 deletions

View File

@ -240,9 +240,8 @@ func (pl *InterPodAffinity) PreFilter(ctx context.Context, cycleState *framework
s := &preFilterState{} s := &preFilterState{}
s.podInfo = framework.NewPodInfo(pod) if s.podInfo, err = framework.NewPodInfo(pod); err != nil {
if s.podInfo.ParseError != nil { return nil, framework.NewStatus(framework.UnschedulableAndUnresolvable, fmt.Sprintf("parsing pod: %+v", err))
return nil, framework.NewStatus(framework.UnschedulableAndUnresolvable, fmt.Sprintf("parsing pod: %+v", s.podInfo.ParseError))
} }
for i := range s.podInfo.RequiredAffinityTerms { for i := range s.podInfo.RequiredAffinityTerms {

View File

@ -162,10 +162,9 @@ func (pl *InterPodAffinity) PreScore(
topologyScore: make(map[string]map[string]int64), topologyScore: make(map[string]map[string]int64),
} }
state.podInfo = framework.NewPodInfo(pod) if state.podInfo, err = framework.NewPodInfo(pod); err != nil {
if state.podInfo.ParseError != nil {
// Ideally we never reach here, because errors will be caught by PreFilter // Ideally we never reach here, because errors will be caught by PreFilter
return framework.AsStatus(fmt.Errorf("failed to parse pod: %w", state.podInfo.ParseError)) return framework.AsStatus(fmt.Errorf("failed to parse pod: %w", err))
} }
for i := range state.podInfo.PreferredAffinityTerms { for i := range state.podInfo.PreferredAffinityTerms {

View File

@ -762,8 +762,11 @@ func (p *PriorityQueue) podsCompareBackoffCompleted(podInfo1, podInfo2 interface
// newQueuedPodInfo builds a QueuedPodInfo object. // newQueuedPodInfo builds a QueuedPodInfo object.
func (p *PriorityQueue) newQueuedPodInfo(pod *v1.Pod, plugins ...string) *framework.QueuedPodInfo { func (p *PriorityQueue) newQueuedPodInfo(pod *v1.Pod, plugins ...string) *framework.QueuedPodInfo {
now := p.clock.Now() now := p.clock.Now()
// ignore this err since apiserver doesn't properly validate affinity terms
// and we can't fix the validation for backwards compatibility.
podInfo, _ := framework.NewPodInfo(pod)
return &framework.QueuedPodInfo{ return &framework.QueuedPodInfo{
PodInfo: framework.NewPodInfo(pod), PodInfo: podInfo,
Timestamp: now, Timestamp: now,
InitialAttemptTimestamp: now, InitialAttemptTimestamp: now,
UnschedulablePlugins: sets.NewString(plugins...), UnschedulablePlugins: sets.NewString(plugins...),

View File

@ -900,7 +900,9 @@ func (sched *Scheduler) handleSchedulingFailure(ctx context.Context, fwk framewo
klog.InfoS("Pod has been assigned to node. Abort adding it back to queue.", "pod", klog.KObj(pod), "node", cachedPod.Spec.NodeName) klog.InfoS("Pod has been assigned to node. Abort adding it back to queue.", "pod", klog.KObj(pod), "node", cachedPod.Spec.NodeName)
} else { } else {
// As <cachedPod> is from SharedInformer, we need to do a DeepCopy() here. // As <cachedPod> is from SharedInformer, we need to do a DeepCopy() here.
podInfo.PodInfo = framework.NewPodInfo(cachedPod.DeepCopy()) // ignore this err since apiserver doesn't properly validate affinity terms
// and we can't fix the validation for backwards compatibility.
podInfo.PodInfo, _ = framework.NewPodInfo(cachedPod.DeepCopy())
if err := sched.SchedulingQueue.AddUnschedulableIfNotPresent(podInfo, sched.SchedulingQueue.SchedulingCycle()); err != nil { if err := sched.SchedulingQueue.AddUnschedulableIfNotPresent(podInfo, sched.SchedulingQueue.SchedulingCycle()); err != nil {
klog.ErrorS(err, "Error occurred") klog.ErrorS(err, "Error occurred")
} }