Skip to content

Commit 74cdc73

Browse files
committed
adapt to Preemption interface change
1 parent 437ac6d commit 74cdc73

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

pkg/capacityscheduling/capacity_scheduling.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@ type preemptor struct {
376376
state *framework.CycleState
377377
}
378378

379+
func (p *preemptor) OrderedScoreFuncs(ctx context.Context, nodesToVictims map[string]*extenderv1.Victims) []func(node string) int64 {
380+
return nil
381+
}
382+
379383
func (p *preemptor) GetOffsetAndNumCandidates(n int32) (int32, int32) {
380384
return 0, n
381385
}
@@ -493,8 +497,9 @@ func (p *preemptor) SelectVictimsOnNode(
493497
var nominatedPodsReqWithPodReq framework.Resource
494498
podReq := preFilterState.podReq
495499

500+
logger := klog.FromContext(ctx)
496501
removePod := func(rpi *framework.PodInfo) error {
497-
if err := nodeInfo.RemovePod(rpi.Pod); err != nil {
502+
if err := nodeInfo.RemovePod(logger, rpi.Pod); err != nil {
498503
return err
499504
}
500505
status := p.fh.RunPreFilterExtensionRemovePod(ctx, state, pod, rpi, nodeInfo)

pkg/coscheduling/core/core.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func (pgMgr *PodGroupManager) PreFilter(ctx context.Context, pod *corev1.Pod) er
200200
minResources := pg.Spec.MinResources.DeepCopy()
201201
podQuantity := resource.NewQuantity(int64(pg.Spec.MinMember), resource.DecimalSI)
202202
minResources[corev1.ResourcePods] = *podQuantity
203-
err = CheckClusterResource(nodes, minResources, pgFullName)
203+
err = CheckClusterResource(ctx, nodes, minResources, pgFullName)
204204
if err != nil {
205205
klog.ErrorS(err, "Failed to PreFilter", "podGroup", klog.KObj(pg))
206206
return err
@@ -295,13 +295,13 @@ func (pgMgr *PodGroupManager) CalculateAssignedPods(podGroupName, namespace stri
295295

296296
// CheckClusterResource checks if resource capacity of the cluster can satisfy <resourceRequest>.
297297
// It returns an error detailing the resource gap if not satisfied; otherwise returns nil.
298-
func CheckClusterResource(nodeList []*framework.NodeInfo, resourceRequest corev1.ResourceList, desiredPodGroupName string) error {
298+
func CheckClusterResource(ctx context.Context, nodeList []*framework.NodeInfo, resourceRequest corev1.ResourceList, desiredPodGroupName string) error {
299299
for _, info := range nodeList {
300300
if info == nil || info.Node() == nil {
301301
continue
302302
}
303303

304-
nodeResource := util.ResourceList(getNodeResource(info, desiredPodGroupName))
304+
nodeResource := util.ResourceList(getNodeResource(ctx, info, desiredPodGroupName))
305305
for name, quant := range resourceRequest {
306306
quant.Sub(nodeResource[name])
307307
if quant.Sign() <= 0 {
@@ -322,16 +322,17 @@ func GetNamespacedName(obj metav1.Object) string {
322322
return fmt.Sprintf("%v/%v", obj.GetNamespace(), obj.GetName())
323323
}
324324

325-
func getNodeResource(info *framework.NodeInfo, desiredPodGroupName string) *framework.Resource {
326-
nodeClone := info.Clone()
325+
func getNodeResource(ctx context.Context, info *framework.NodeInfo, desiredPodGroupName string) *framework.Resource {
326+
nodeClone := info.Snapshot()
327+
logger := klog.FromContext(ctx)
327328
for _, podInfo := range info.Pods {
328329
if podInfo == nil || podInfo.Pod == nil {
329330
continue
330331
}
331332
if util.GetPodGroupFullName(podInfo.Pod) != desiredPodGroupName {
332333
continue
333334
}
334-
nodeClone.RemovePod(podInfo.Pod)
335+
nodeClone.RemovePod(logger, podInfo.Pod)
335336
}
336337

337338
leftResource := framework.Resource{

pkg/coscheduling/core/core_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ func TestCheckClusterResource(t *testing.T) {
349349
t.Run(tt.name, func(t *testing.T) {
350350
snapshotSharedLister := tu.NewFakeSharedLister(tt.existingPods, nodes)
351351
nodeInfoList, _ := snapshotSharedLister.NodeInfos().List()
352-
err := CheckClusterResource(nodeInfoList, tt.minResources, tt.pgName)
352+
err := CheckClusterResource(context.Background(), nodeInfoList, tt.minResources, tt.pgName)
353353
if (err == nil) != tt.want {
354354
t.Errorf("Expect the cluster resource to be satified: %v, but got %v", tt.want, err == nil)
355355
}

pkg/preemptiontoleration/preemption_toleration.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ type PreemptionToleration struct {
6969
curTime time.Time
7070
}
7171

72+
func (pl *PreemptionToleration) OrderedScoreFuncs(ctx context.Context, nodesToVictims map[string]*extenderv1.Victims) []func(node string) int64 {
73+
return nil
74+
}
75+
7276
// Name returns name of the plugin. It is used in logs, etc.
7377
func (pl *PreemptionToleration) Name() string {
7478
return Name
@@ -184,8 +188,9 @@ func (pl *PreemptionToleration) SelectVictimsOnNode(
184188
nodeInfo *framework.NodeInfo,
185189
pdbs []*policy.PodDisruptionBudget) ([]*v1.Pod, int, *framework.Status) {
186190
var potentialVictims []*framework.PodInfo
191+
logger := klog.FromContext(ctx)
187192
removePod := func(rpi *framework.PodInfo) error {
188-
if err := nodeInfo.RemovePod(rpi.Pod); err != nil {
193+
if err := nodeInfo.RemovePod(logger, rpi.Pod); err != nil {
189194
return err
190195
}
191196
status := pl.fh.RunPreFilterExtensionRemovePod(ctx, state, preemptor, rpi, nodeInfo)

0 commit comments

Comments
 (0)