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-1.9] Scheduler doesn't reschedule vpods that are scheduled on unscehdulable pods #6730

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
9 changes: 9 additions & 0 deletions pkg/scheduler/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ func (s *State) GetPodInfo(podName string) (zoneName string, nodeName string, er
return zoneName, nodeName, nil
}

func (s *State) IsSchedulablePod(ordinal int32) bool {
for _, x := range s.SchedulablePods {
if x == ordinal {
return true
}
}
return false
}

// stateBuilder reconstruct the state from scratch, by listing vpods
type stateBuilder struct {
ctx context.Context
Expand Down
14 changes: 12 additions & 2 deletions pkg/scheduler/statefulset/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,20 @@ func (s *StatefulSetScheduler) scheduleVPod(vpod scheduler.VPod) ([]duckv1alpha1
return nil, err
}

placements := vpod.GetPlacements()
existingPlacements := placements
existingPlacements := vpod.GetPlacements()
var left int32

// Remove unschedulable pods from placements
var placements []duckv1alpha1.Placement
if len(existingPlacements) > 0 {
placements = make([]duckv1alpha1.Placement, 0, len(existingPlacements))
for _, p := range existingPlacements {
if state.IsSchedulablePod(st.OrdinalFromPodName(p.PodName)) {
placements = append(placements, *p.DeepCopy())
}
}
}

// The scheduler when policy type is
// Policy: MAXFILLUP (SchedulerPolicyType == MAXFILLUP)
// - allocates as many vreplicas as possible to the same pod(s)
Expand Down
26 changes: 26 additions & 0 deletions pkg/scheduler/statefulset/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,32 @@ func TestStatefulsetScheduler(t *testing.T) {
expected: []duckv1alpha1.Placement{{PodName: "statefulset-name-0", VReplicas: 3}},
schedulerPolicyType: scheduler.MAXFILLUP,
},
{
name: "one replica, 8 vreplicas, already scheduled on unschedulable pod, add replicas",
vreplicas: 8,
replicas: int32(1),
placements: []duckv1alpha1.Placement{
{PodName: "statefulset-name-0", VReplicas: 3},
{PodName: "statefulset-name-2", VReplicas: 5},
},
expected: []duckv1alpha1.Placement{
{PodName: "statefulset-name-0", VReplicas: 8},
},
schedulerPolicyType: scheduler.MAXFILLUP,
},
{
name: "one replica, 1 vreplicas, already scheduled on unschedulable pod, remove replicas",
vreplicas: 1,
replicas: int32(1),
placements: []duckv1alpha1.Placement{
{PodName: "statefulset-name-0", VReplicas: 3},
{PodName: "statefulset-name-2", VReplicas: 5},
},
expected: []duckv1alpha1.Placement{
{PodName: "statefulset-name-0", VReplicas: 1},
},
schedulerPolicyType: scheduler.MAXFILLUP,
},
{
name: "one replica, 15 vreplicas, unschedulable",
vreplicas: 15,
Expand Down