@@ -33,6 +33,7 @@ import (
3333 listerv1 "k8s.io/client-go/listers/core/v1"
3434 "k8s.io/client-go/tools/cache"
3535 "k8s.io/klog/v2"
36+ fwk "k8s.io/kube-scheduler/framework"
3637 "k8s.io/kubernetes/pkg/scheduler/framework"
3738 "sigs.k8s.io/controller-runtime/pkg/client"
3839
@@ -58,20 +59,20 @@ type PermitState struct {
5859 Activate bool
5960}
6061
61- func (s * PermitState ) Clone () framework .StateData {
62+ func (s * PermitState ) Clone () fwk .StateData {
6263 return & PermitState {Activate : s .Activate }
6364}
6465
6566// Manager defines the interfaces for PodGroup management.
6667type Manager interface {
6768 PreFilter (context.Context , * corev1.Pod ) error
68- Permit (context.Context , * framework .CycleState , * corev1.Pod ) Status
69+ Permit (context.Context , fwk .CycleState , * corev1.Pod ) Status
6970 Unreserve (context.Context , * corev1.Pod )
7071 GetPodGroup (context.Context , * corev1.Pod ) (string , * v1alpha1.PodGroup )
7172 GetAssignedPodCount (string ) int
7273 GetCreationTimestamp (context.Context , * corev1.Pod , time.Time ) time.Time
7374 DeletePermittedPodGroup (context.Context , string )
74- ActivateSiblings (ctx context.Context , pod * corev1.Pod , state * framework .CycleState )
75+ ActivateSiblings (ctx context.Context , pod * corev1.Pod , state fwk .CycleState )
7576 BackoffPodGroup (string , time.Duration )
7677}
7778
@@ -173,7 +174,7 @@ func (pgMgr *PodGroupManager) BackoffPodGroup(pgName string, backoff time.Durati
173174
174175// ActivateSiblings stashes the pods belonging to the same PodGroup of the given pod
175176// in the given state, with a reserved key "kubernetes.io/pods-to-activate".
176- func (pgMgr * PodGroupManager ) ActivateSiblings (ctx context.Context , pod * corev1.Pod , state * framework .CycleState ) {
177+ func (pgMgr * PodGroupManager ) ActivateSiblings (ctx context.Context , pod * corev1.Pod , state fwk .CycleState ) {
177178 lh := klog .FromContext (ctx )
178179 pgName := util .GetPodGroupLabel (pod )
179180 if pgName == "" {
@@ -273,7 +274,7 @@ func (pgMgr *PodGroupManager) PreFilter(ctx context.Context, pod *corev1.Pod) er
273274}
274275
275276// Permit permits a pod to run, if the minMember match, it would send a signal to chan.
276- func (pgMgr * PodGroupManager ) Permit (ctx context.Context , state * framework .CycleState , pod * corev1.Pod ) Status {
277+ func (pgMgr * PodGroupManager ) Permit (ctx context.Context , state fwk .CycleState , pod * corev1.Pod ) Status {
277278 pgFullName , pg := pgMgr .GetPodGroup (ctx , pod )
278279 if pgFullName == "" {
279280 return PodGroupNotSpecified
@@ -363,7 +364,7 @@ func (pgMgr *PodGroupManager) GetPodGroup(ctx context.Context, pod *corev1.Pod)
363364
364365// CheckClusterResource checks if resource capacity of the cluster can satisfy <resourceRequest>.
365366// It returns an error detailing the resource gap if not satisfied; otherwise returns nil.
366- func CheckClusterResource (ctx context.Context , nodeList []* framework .NodeInfo , resourceRequest corev1.ResourceList , desiredPodGroupName string ) error {
367+ func CheckClusterResource (ctx context.Context , nodeList []fwk .NodeInfo , resourceRequest corev1.ResourceList , desiredPodGroupName string ) error {
367368 for _ , info := range nodeList {
368369 if info == nil || info .Node () == nil {
369370 continue
@@ -390,32 +391,32 @@ func GetNamespacedName(obj metav1.Object) string {
390391 return fmt .Sprintf ("%v/%v" , obj .GetNamespace (), obj .GetName ())
391392}
392393
393- func getNodeResource (ctx context.Context , info * framework .NodeInfo , desiredPodGroupName string ) * framework .Resource {
394+ func getNodeResource (ctx context.Context , info fwk .NodeInfo , desiredPodGroupName string ) fwk .Resource {
394395 nodeClone := info .Snapshot ()
395396 logger := klog .FromContext (ctx )
396- for _ , podInfo := range info .Pods {
397- if podInfo == nil || podInfo .Pod == nil {
397+ for _ , podInfo := range info .GetPods () {
398+ if podInfo == nil || podInfo .GetPod () == nil {
398399 continue
399400 }
400- if util .GetPodGroupFullName (podInfo .Pod ) != desiredPodGroupName {
401+ if util .GetPodGroupFullName (podInfo .GetPod () ) != desiredPodGroupName {
401402 continue
402403 }
403- nodeClone .RemovePod (logger , podInfo .Pod )
404+ nodeClone .RemovePod (logger , podInfo .GetPod () )
404405 }
405406
406407 leftResource := framework.Resource {
407408 ScalarResources : make (map [corev1.ResourceName ]int64 ),
408409 }
409- allocatable := nodeClone .Allocatable
410- requested := nodeClone .Requested
410+ allocatable := nodeClone .GetAllocatable ()
411+ requested := nodeClone .GetRequested ()
411412
412- leftResource .AllowedPodNumber = allocatable .AllowedPodNumber - len (nodeClone .Pods )
413- leftResource .MilliCPU = allocatable .MilliCPU - requested .MilliCPU
414- leftResource .Memory = allocatable .Memory - requested .Memory
415- leftResource .EphemeralStorage = allocatable .EphemeralStorage - requested .EphemeralStorage
413+ leftResource .AllowedPodNumber = allocatable .GetAllowedPodNumber () - len (nodeClone .GetPods () )
414+ leftResource .MilliCPU = allocatable .GetMilliCPU () - requested .GetMilliCPU ()
415+ leftResource .Memory = allocatable .GetMemory () - requested .GetMemory ()
416+ leftResource .EphemeralStorage = allocatable .GetEphemeralStorage () - requested .GetEphemeralStorage ()
416417
417- for k , allocatableEx := range allocatable .ScalarResources {
418- requestEx , ok := requested .ScalarResources [k ]
418+ for k , allocatableEx := range allocatable .GetScalarResources () {
419+ requestEx , ok := requested .GetScalarResources () [k ]
419420 if ! ok {
420421 leftResource .ScalarResources [k ] = allocatableEx
421422 } else {
0 commit comments