Skip to content

Commit 19e4c4b

Browse files
[release-1.15] Schduler: MAXFILLUP strategy will spread vreplicas across multiple pods (#8290)
* Schduler: MAXFILLUP strategy will spread vreplicas across multiple pods the MAXFILLUP algorithm was using an affinity strategy, meaning that it would prioritize adding new vreplicas to pods with the same resources. However, the downside is that if one pod goes down or gets re-scheduled the entire resource would be down and not produce events. By spreading replicas across multiple real replicas we would guarantee better availability. Signed-off-by: Pierangelo Di Pilato <[email protected]> * Remove configurable HA scheduler, fix reserved replicas logic Signed-off-by: Pierangelo Di Pilato <[email protected]> * Log reserved Signed-off-by: Pierangelo Di Pilato <[email protected]> * Handle unschedulables pods and always start from reserved no matter what is placements Signed-off-by: Pierangelo Di Pilato <[email protected]> * Add reserved + overcommit Signed-off-by: Pierangelo Di Pilato <[email protected]> * Add benchmark + reduce OrdinalFromPodName calls Signed-off-by: Pierangelo Di Pilato <[email protected]> * Handle unschedulable pods Signed-off-by: Pierangelo Di Pilato <[email protected]> --------- Signed-off-by: Pierangelo Di Pilato <[email protected]> Co-authored-by: Pierangelo Di Pilato <[email protected]>
1 parent 86d5cc6 commit 19e4c4b

37 files changed

+865
-5904
lines changed

pkg/scheduler/README.md

Lines changed: 50 additions & 203 deletions
Large diffs are not rendered by default.

pkg/scheduler/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// The scheduler is responsible for placing virtual pod (VPod) replicas within real pods.
17+
// Package scheduler is responsible for placing virtual pod (VPod) replicas within real pods.
1818
package scheduler

pkg/scheduler/factory/registry.go

Lines changed: 0 additions & 88 deletions
This file was deleted.

pkg/scheduler/placement.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package scheduler
1818

1919
import (
20-
"k8s.io/apimachinery/pkg/util/sets"
2120
duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1"
2221
)
2322

@@ -29,24 +28,3 @@ func GetTotalVReplicas(placements []duckv1alpha1.Placement) int32 {
2928
}
3029
return r
3130
}
32-
33-
// GetPlacementForPod returns the placement corresponding to podName
34-
func GetPlacementForPod(placements []duckv1alpha1.Placement, podName string) *duckv1alpha1.Placement {
35-
for i := 0; i < len(placements); i++ {
36-
if placements[i].PodName == podName {
37-
return &placements[i]
38-
}
39-
}
40-
return nil
41-
}
42-
43-
// GetPodCount returns the number of pods with the given placements
44-
func GetPodCount(placements []duckv1alpha1.Placement) int {
45-
set := sets.NewString()
46-
for _, p := range placements {
47-
if p.VReplicas > 0 {
48-
set.Insert(p.PodName)
49-
}
50-
}
51-
return set.Len()
52-
}

pkg/scheduler/placement_test.go

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -62,95 +62,3 @@ func TestGetTotalVReplicas(t *testing.T) {
6262
})
6363
}
6464
}
65-
66-
func TestGetPlacementForPod(t *testing.T) {
67-
ps1 := []duckv1alpha1.Placement{{PodName: "p", VReplicas: 2}}
68-
ps2 := []duckv1alpha1.Placement{{PodName: "p", VReplicas: 2}, {PodName: "p2", VReplicas: 4}}
69-
testCases := []struct {
70-
name string
71-
podName string
72-
placements []duckv1alpha1.Placement
73-
expected *duckv1alpha1.Placement
74-
}{
75-
{
76-
name: "nil placements",
77-
podName: "p",
78-
placements: nil,
79-
expected: nil,
80-
},
81-
{
82-
name: "empty placements",
83-
podName: "p",
84-
placements: []duckv1alpha1.Placement{},
85-
expected: nil,
86-
},
87-
{
88-
name: "one placement",
89-
placements: ps1,
90-
podName: "p",
91-
expected: &ps1[0],
92-
}, {
93-
name: "mayne placements",
94-
placements: ps2,
95-
podName: "p2",
96-
expected: &ps2[1],
97-
},
98-
}
99-
100-
for _, tc := range testCases {
101-
t.Run(tc.name, func(t *testing.T) {
102-
got := GetPlacementForPod(tc.placements, tc.podName)
103-
if got != tc.expected {
104-
t.Errorf("got %v, want %v", got, tc.expected)
105-
}
106-
})
107-
}
108-
}
109-
func TestPodCount(t *testing.T) {
110-
testCases := []struct {
111-
name string
112-
placements []duckv1alpha1.Placement
113-
expected int
114-
}{
115-
{
116-
name: "nil placements",
117-
placements: nil,
118-
expected: 0,
119-
},
120-
{
121-
name: "empty placements",
122-
placements: []duckv1alpha1.Placement{},
123-
expected: 0,
124-
},
125-
{
126-
name: "one pod",
127-
placements: []duckv1alpha1.Placement{{PodName: "d", VReplicas: 2}},
128-
expected: 1,
129-
},
130-
{
131-
name: "two pods",
132-
placements: []duckv1alpha1.Placement{
133-
{PodName: "p1", VReplicas: 2},
134-
{PodName: "p2", VReplicas: 6},
135-
{PodName: "p1", VReplicas: 6}},
136-
expected: 2,
137-
},
138-
{
139-
name: "three pods, one with no vreplicas",
140-
placements: []duckv1alpha1.Placement{
141-
{PodName: "p1", VReplicas: 2},
142-
{PodName: "p2", VReplicas: 6},
143-
{PodName: "p1", VReplicas: 0}},
144-
expected: 2,
145-
},
146-
}
147-
148-
for _, tc := range testCases {
149-
t.Run(tc.name, func(t *testing.T) {
150-
got := GetPodCount(tc.placements)
151-
if got != tc.expected {
152-
t.Errorf("got %v, want %v", got, tc.expected)
153-
}
154-
})
155-
}
156-
}

pkg/scheduler/plugins/core/availabilitynodepriority/availability_node_priority.go

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)