Skip to content

Commit

Permalink
scheduler: enhance deviceshare error message for reservation
Browse files Browse the repository at this point in the history
Signed-off-by: saintube <saintube@foxmail.com>
  • Loading branch information
saintube committed May 23, 2024
1 parent 7f259d5 commit 2ef40d5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/scheduler/plugins/deviceshare/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2058,7 +2058,7 @@ func Test_Plugin_FilterReservation(t *testing.T) {
assert.True(t, status.IsSuccess())

status = pl.FilterReservation(context.TODO(), cycleState, pod, reservationInfo, "test-node-1")
assert.Equal(t, framework.NewStatus(framework.Unschedulable, "Insufficient gpu devices by reservation"), status)
assert.Equal(t, framework.NewStatus(framework.Unschedulable, "Reservation(s) Insufficient gpu devices"), status)
}

func Test_Plugin_Reserve(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/plugins/deviceshare/reservation.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (p *Plugin) makeReasonsByReservation(reservationReasons []*framework.Status
var reasons []string
for _, status := range reservationReasons {
for _, r := range status.Reasons() {
reasons = append(reasons, fmt.Sprintf("%s by reservation", r))
reasons = append(reasons, fmt.Sprintf("Reservation(s) %s", r))
}
}
return reasons
Expand Down
6 changes: 3 additions & 3 deletions pkg/scheduler/plugins/deviceshare/reservation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ func Test_tryAllocateFromReservation(t *testing.T) {
},
requiredFromReservation: true,
wantResult: nil,
wantStatus: framework.NewStatus(framework.Unschedulable, "Insufficient gpu devices by reservation"),
wantStatus: framework.NewStatus(framework.Unschedulable, "Reservation(s) Insufficient gpu devices"),
},
{
name: "failed to allocate from Aligned policy reservation that remaining little not fits request",
Expand Down Expand Up @@ -566,7 +566,7 @@ func Test_tryAllocateFromReservation(t *testing.T) {
},
requiredFromReservation: true,
wantResult: nil,
wantStatus: framework.NewStatus(framework.Unschedulable, "Insufficient gpu devices by reservation"),
wantStatus: framework.NewStatus(framework.Unschedulable, "Reservation(s) Insufficient gpu devices"),
},
{
name: "allocate from Restricted policy reservation",
Expand Down Expand Up @@ -650,7 +650,7 @@ func Test_tryAllocateFromReservation(t *testing.T) {
},
requiredFromReservation: true,
wantResult: nil,
wantStatus: framework.NewStatus(framework.Unschedulable, "Insufficient gpu devices by reservation"),
wantStatus: framework.NewStatus(framework.Unschedulable, "Reservation(s) Insufficient gpu devices"),
},
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/plugins/reservation/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func (pl *Plugin) filterWithReservations(ctx context.Context, cycleState *framew
failureReasons = append(failureReasons, fmt.Sprintf("Insufficient %s by node", insufficientResourceByNode))
}
for _, insufficientResourceByReservation := range allInsufficientResourcesByReservation {
failureReasons = append(failureReasons, fmt.Sprintf("Insufficient %s by reservation", insufficientResourceByReservation))
failureReasons = append(failureReasons, fmt.Sprintf("Reservation(s) Insufficient %s", insufficientResourceByReservation))
}
if len(failureReasons) == 0 {
failureReasons = append(failureReasons, ErrReasonNoReservationsMeetRequirements)
Expand Down
8 changes: 4 additions & 4 deletions pkg/scheduler/plugins/reservation/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ func Test_filterWithReservations(t *testing.T) {
},
},
},
wantStatus: framework.NewStatus(framework.Unschedulable, "Insufficient cpu by reservation"),
wantStatus: framework.NewStatus(framework.Unschedulable, "Reservation(s) Insufficient cpu"),
},
{
name: "filter default reservations with preemption",
Expand Down Expand Up @@ -1160,7 +1160,7 @@ func Test_filterWithReservations(t *testing.T) {
},
},
},
wantStatus: framework.NewStatus(framework.Unschedulable, "Insufficient cpu by reservation"),
wantStatus: framework.NewStatus(framework.Unschedulable, "Reservation(s) Insufficient cpu"),
},
{
name: "failed to filter multiple restricted reservations with preempt from node",
Expand Down Expand Up @@ -1227,7 +1227,7 @@ func Test_filterWithReservations(t *testing.T) {
},
},
},
wantStatus: framework.NewStatus(framework.Unschedulable, "Insufficient cpu by reservation", "Insufficient cpu by reservation"),
wantStatus: framework.NewStatus(framework.Unschedulable, "Reservation(s) Insufficient cpu", "Reservation(s) Insufficient cpu"),
},
{
name: "failed to filter restricted reservations with preempt from reservation and node",
Expand Down Expand Up @@ -1284,7 +1284,7 @@ func Test_filterWithReservations(t *testing.T) {
},
},
},
wantStatus: framework.NewStatus(framework.Unschedulable, "Insufficient cpu by reservation"),
wantStatus: framework.NewStatus(framework.Unschedulable, "Reservation(s) Insufficient cpu"),
},
{
name: "filter restricted reservations with preempt from reservation and node",
Expand Down

0 comments on commit 2ef40d5

Please sign in to comment.