Skip to content
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
6 changes: 6 additions & 0 deletions .changes/unreleased/fixed-20261028-174735.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixed
body: |-
Scheduler patches a pending pod's PodScheduled condition only when it changes, not every cycle
custom:
Author: "sam-huang1223"
Issue: "2544"
9 changes: 6 additions & 3 deletions pkg/scheduler/cache/pod_transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ func compactContainerStatuses(statuses []v1.ContainerStatus) []v1.ContainerStatu
return compact
}

// compactConditions keeps PodResizePending for resize accounting and PodScheduled, which the status
// updater compares against so it patches the condition only when it changes.
func compactConditions(conditions []v1.PodCondition) []v1.PodCondition {
var compact []v1.PodCondition
for _, c := range conditions {
if c.Type == v1.PodResizePending {
return []v1.PodCondition{c}
if c.Type == v1.PodResizePending || c.Type == v1.PodScheduled {
compact = append(compact, c)
}
}
return nil
return compact
}

func compactContainers(containers []v1.Container) []v1.Container {
Expand Down
20 changes: 20 additions & 0 deletions pkg/scheduler/cache/pod_transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,25 @@ var _ = Describe("compactSchedulerPod", func() {
Expect(compact.Annotations).To(HaveLen(2))
Expect(compact.ManagedFields).To(BeNil())
})

It("keeps PodScheduled, which the status updater compares before patching it", func() {
pod := succeededPod()
pod.Status.Phase = v1.PodPending
unschedulable := v1.PodCondition{
Type: v1.PodScheduled,
Status: v1.ConditionFalse,
Reason: v1.PodReasonUnschedulable,
Message: "no nodes with enough resources",
LastTransitionTime: metav1.Unix(1767323045, 0),
}
resizePending := v1.PodCondition{Type: v1.PodResizePending, Status: v1.ConditionTrue}
pod.Status.Conditions = []v1.PodCondition{unschedulable, {Type: v1.PodReady}, resizePending}

transformed, err := compactSchedulerPod(pod)
Expect(err).NotTo(HaveOccurred())

compact := transformed.(*v1.Pod)
Expect(compact.Status.Conditions).To(Equal([]v1.PodCondition{unschedulable, resizePending}))
})
})
})
Loading