@@ -33,6 +33,7 @@ import (
3333 "k8s.io/kubernetes/pkg/scheduler/framework/parallelize"
3434 schedutil "k8s.io/kubernetes/pkg/scheduler/util"
3535
36+ "github.com/koordinator-sh/koordinator/apis/extension"
3637 "github.com/koordinator-sh/koordinator/pkg/scheduler/frameworkext"
3738 "github.com/koordinator-sh/koordinator/pkg/util"
3839 reservationutil "github.com/koordinator-sh/koordinator/pkg/util/reservation"
@@ -61,6 +62,13 @@ func (pl *Plugin) prepareMatchReservationState(ctx context.Context, cycleState *
6162 }
6263 requiredNodeAffinity := nodeaffinity .GetRequiredNodeAffinity (pod )
6364
65+ podRequests := resourceapi .PodRequests (pod , resourceapi.PodResourcesOptions {})
66+ exactMatchReservationSpec , err := extension .GetExactMatchReservationSpec (pod .Annotations )
67+ if err != nil {
68+ klog .ErrorS (err , "Failed to parse exact match reservation spec" , "pod" , klog .KObj (pod ))
69+ return nil , false , framework .AsStatus (err )
70+ }
71+
6472 var stateIndex , diagnosisIndex int32
6573 allNodes := pl .reservationCache .listAllNodes ()
6674 allNodeReservationStates := make ([]* nodeReservationState , len (allNodes ))
@@ -106,6 +114,7 @@ func (pl *Plugin) prepareMatchReservationState(ctx context.Context, cycleState *
106114 ownerMatched : 0 ,
107115 isUnschedulableUnmatched : 0 ,
108116 affinityUnmatched : 0 ,
117+ notExactMatched : 0 ,
109118 }
110119 status := pl .reservationCache .forEachAvailableReservationOnNode (node .Name , func (rInfo * frameworkext.ReservationInfo ) (bool , * framework.Status ) {
111120 if ! rInfo .IsAvailable () || rInfo .ParseError != nil {
@@ -121,7 +130,8 @@ func (pl *Plugin) prepareMatchReservationState(ctx context.Context, cycleState *
121130 isOwnerMatched := rInfo .Match (pod )
122131 isUnschedulable := rInfo .IsUnschedulable ()
123132 isMatchReservationAffinity := matchReservationAffinity (node , rInfo , reservationAffinity )
124- if ! isReservedPod && ! isUnschedulable && isOwnerMatched && isMatchReservationAffinity {
133+ isExactMatched := extension .ExactMatchReservation (podRequests , rInfo .Allocatable , exactMatchReservationSpec )
134+ if ! isReservedPod && ! isUnschedulable && isOwnerMatched && isMatchReservationAffinity && isExactMatched {
125135 matched = append (matched , rInfo .Clone ())
126136
127137 } else if len (rInfo .AssignedPods ) > 0 {
@@ -133,6 +143,8 @@ func (pl *Plugin) prepareMatchReservationState(ctx context.Context, cycleState *
133143 diagnosisState .isUnschedulableUnmatched ++
134144 } else if ! isMatchReservationAffinity {
135145 diagnosisState .affinityUnmatched ++
146+ } else if ! isExactMatched {
147+ diagnosisState .notExactMatched ++
136148 }
137149 }
138150
@@ -224,8 +236,6 @@ func (pl *Plugin) prepareMatchReservationState(ctx context.Context, cycleState *
224236 allNodeReservationStates = allNodeReservationStates [:stateIndex ]
225237 allPluginToRestoreState = allPluginToRestoreState [:stateIndex ]
226238 allNodeDiagnosisStates = allNodeDiagnosisStates [:diagnosisIndex ]
227-
228- podRequests := resourceapi .PodRequests (pod , resourceapi.PodResourcesOptions {})
229239 podRequestResources := framework .NewResource (podRequests )
230240 state := & stateData {
231241 hasAffinity : reservationAffinity != nil ,
0 commit comments