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.15] Schduler: MAXFILLUP strategy will spread vreplicas across multiple pods #8290

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
253 changes: 50 additions & 203 deletions pkg/scheduler/README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/scheduler/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// The scheduler is responsible for placing virtual pod (VPod) replicas within real pods.
// Package scheduler is responsible for placing virtual pod (VPod) replicas within real pods.
package scheduler
88 changes: 0 additions & 88 deletions pkg/scheduler/factory/registry.go

This file was deleted.

22 changes: 0 additions & 22 deletions pkg/scheduler/placement.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package scheduler

import (
"k8s.io/apimachinery/pkg/util/sets"
duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1"
)

Expand All @@ -29,24 +28,3 @@ func GetTotalVReplicas(placements []duckv1alpha1.Placement) int32 {
}
return r
}

// GetPlacementForPod returns the placement corresponding to podName
func GetPlacementForPod(placements []duckv1alpha1.Placement, podName string) *duckv1alpha1.Placement {
for i := 0; i < len(placements); i++ {
if placements[i].PodName == podName {
return &placements[i]
}
}
return nil
}

// GetPodCount returns the number of pods with the given placements
func GetPodCount(placements []duckv1alpha1.Placement) int {
set := sets.NewString()
for _, p := range placements {
if p.VReplicas > 0 {
set.Insert(p.PodName)
}
}
return set.Len()
}
92 changes: 0 additions & 92 deletions pkg/scheduler/placement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,95 +62,3 @@ func TestGetTotalVReplicas(t *testing.T) {
})
}
}

func TestGetPlacementForPod(t *testing.T) {
ps1 := []duckv1alpha1.Placement{{PodName: "p", VReplicas: 2}}
ps2 := []duckv1alpha1.Placement{{PodName: "p", VReplicas: 2}, {PodName: "p2", VReplicas: 4}}
testCases := []struct {
name string
podName string
placements []duckv1alpha1.Placement
expected *duckv1alpha1.Placement
}{
{
name: "nil placements",
podName: "p",
placements: nil,
expected: nil,
},
{
name: "empty placements",
podName: "p",
placements: []duckv1alpha1.Placement{},
expected: nil,
},
{
name: "one placement",
placements: ps1,
podName: "p",
expected: &ps1[0],
}, {
name: "mayne placements",
placements: ps2,
podName: "p2",
expected: &ps2[1],
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
got := GetPlacementForPod(tc.placements, tc.podName)
if got != tc.expected {
t.Errorf("got %v, want %v", got, tc.expected)
}
})
}
}
func TestPodCount(t *testing.T) {
testCases := []struct {
name string
placements []duckv1alpha1.Placement
expected int
}{
{
name: "nil placements",
placements: nil,
expected: 0,
},
{
name: "empty placements",
placements: []duckv1alpha1.Placement{},
expected: 0,
},
{
name: "one pod",
placements: []duckv1alpha1.Placement{{PodName: "d", VReplicas: 2}},
expected: 1,
},
{
name: "two pods",
placements: []duckv1alpha1.Placement{
{PodName: "p1", VReplicas: 2},
{PodName: "p2", VReplicas: 6},
{PodName: "p1", VReplicas: 6}},
expected: 2,
},
{
name: "three pods, one with no vreplicas",
placements: []duckv1alpha1.Placement{
{PodName: "p1", VReplicas: 2},
{PodName: "p2", VReplicas: 6},
{PodName: "p1", VReplicas: 0}},
expected: 2,
},
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
got := GetPodCount(tc.placements)
if got != tc.expected {
t.Errorf("got %v, want %v", got, tc.expected)
}
})
}
}

This file was deleted.

Loading
Loading