Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-0.7] Fix panic when not enough quota on FairSharing enabled. #2449

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func (s *Scheduler) nominate(ctx context.Context, workloads []workload.Info, sna
e.assignment, e.preemptionTargets = s.getAssignments(log, &e.Info, &snap)
e.inadmissibleMsg = e.assignment.Message()
e.Info.LastAssignment = &e.assignment.LastState
if s.fairSharing.Enable {
if s.fairSharing.Enable && e.assignment.RepresentativeMode() != flavorassigner.NoFit {
e.dominantResourceShare, e.dominantResourceName = cq.DominantResourceShareWith(e.assignment.TotalRequestsFor(&w))
}
}
Expand Down
27 changes: 27 additions & 0 deletions pkg/scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,33 @@ func TestSchedule(t *testing.T) {
"eng-gamma/gamma4": *utiltesting.MakeAdmission("eng-gamma").Assignment(corev1.ResourceCPU, "on-demand", "20").Obj(),
},
},
"not enough resources": {
workloads: []kueue.Workload{
*utiltesting.MakeWorkload("new", "sales").
Queue("main").
PodSets(*utiltesting.MakePodSet("one", 1).
Request(corev1.ResourceCPU, "100").
Obj()).
Obj(),
},
wantLeft: map[string][]string{
"sales": {"sales/new"},
},
},
"not enough resources with fair sharing enabled": {
enableFairSharing: true,
workloads: []kueue.Workload{
*utiltesting.MakeWorkload("new", "sales").
Queue("main").
PodSets(*utiltesting.MakePodSet("one", 1).
Request(corev1.ResourceCPU, "100").
Obj()).
Obj(),
},
wantLeft: map[string][]string{
"sales": {"sales/new"},
},
},
}

for name, tc := range cases {
Expand Down
20 changes: 20 additions & 0 deletions test/integration/scheduler/fairsharing/fair_sharing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,26 @@ var _ = ginkgo.Describe("Scheduler", func() {
g.Expect(createdCqA.Status.FairSharing).Should(gomega.BeComparableTo(&kueue.FairSharingStatus{WeightedShare: 125}))
}, util.Timeout, util.Interval).Should(gomega.Succeed())
})

ginkgo.It("Shouldn't reserve quota because not enough resources", func() {
wl := testing.MakeWorkload("wl", ns.Name).
Queue(lqA.Name).
Request("cpu", "10").
Obj()
gomega.Expect(k8sClient.Create(ctx, wl)).Should(gomega.Succeed())

gomega.Eventually(func(g gomega.Gomega) {
g.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(wl), wl)).Should(gomega.Succeed())
g.Expect(wl.Status.Conditions).To(gomega.ContainElements(
gomega.BeComparableTo(metav1.Condition{
Type: kueue.WorkloadQuotaReserved,
Status: metav1.ConditionFalse,
Reason: "Pending",
Message: "couldn't assign flavors to pod set main: insufficient unused quota in cohort for cpu in flavor default, 2 more needed",
}, util.IgnoreConditionTimestampsAndObservedGeneration),
))
}, util.Timeout, util.Interval).Should(gomega.Succeed())
})
})

ginkgo.When("Preemption is enabled", func() {
Expand Down