Skip to content

Commit

Permalink
koord-scheduler: skip daemonset usageThreshold check (#1243)
Browse files Browse the repository at this point in the history
Signed-off-by: wangjianyu.wjy <wangjianyu.wjy@alibaba-inc.com>
Co-authored-by: wangjianyu.wjy <wangjianyu.wjy@alibaba-inc.com>
  • Loading branch information
ZiMengSheng and wangjianyu.wjy committed Apr 26, 2023
1 parent 3f9fb9a commit fc10219
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/scheduler/plugins/loadaware/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,13 @@ func sumPodUsages(podMetrics map[string]corev1.ResourceList, estimatedPods sets.
}
return podUsages, estimatedPodsUsages
}

// isDaemonSetPod returns true if the pod is a IsDaemonSetPod.
func isDaemonSetPod(ownerRefList []metav1.OwnerReference) bool {
for _, ownerRef := range ownerRefList {
if ownerRef.Kind == "DaemonSet" {
return true
}
}
return false
}
4 changes: 4 additions & 0 deletions pkg/scheduler/plugins/loadaware/load_aware.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ func (p *Plugin) Filter(ctx context.Context, state *framework.CycleState, pod *c
return framework.NewStatus(framework.Error, "node not found")
}

if isDaemonSetPod(pod.OwnerReferences) {
return nil
}

nodeMetric, err := p.nodeMetricLister.Get(node.Name)
if err != nil {
// For nodes that lack load information, fall back to the situation where there is no load-aware scheduling.
Expand Down
30 changes: 30 additions & 0 deletions pkg/scheduler/plugins/loadaware/load_aware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/client-go/informers"
Expand Down Expand Up @@ -770,6 +771,35 @@ func TestFilterUsage(t *testing.T) {
testPod: schedulertesting.MakePod().Namespace("default").Name("prod-pod-3").Priority(extension.PriorityProdValueMax).Obj(),
wantStatus: framework.NewStatus(framework.Unschedulable, fmt.Sprintf(ErrReasonUsageExceedThreshold, corev1.ResourceMemory)),
},
{
name: "filter daemonset pod exceed cpu usage",
nodeName: "test-node-1",
nodeMetric: &slov1alpha1.NodeMetric{
ObjectMeta: metav1.ObjectMeta{
Name: "test-node-1",
},
Spec: slov1alpha1.NodeMetricSpec{
CollectPolicy: &slov1alpha1.NodeMetricCollectPolicy{
ReportIntervalSeconds: pointer.Int64(60),
},
},
Status: slov1alpha1.NodeMetricStatus{
UpdateTime: &metav1.Time{
Time: time.Now(),
},
NodeMetric: &slov1alpha1.NodeMetricInfo{
NodeUsage: slov1alpha1.ResourceMap{
ResourceList: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("70"),
corev1.ResourceMemory: resource.MustParse("256Gi"),
},
},
},
},
},
testPod: schedulertesting.MakePod().Namespace("default").Name("test-pod").Priority(extension.PriorityProdValueMax).OwnerReference("test-daemonset", schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "DaemonSet"}).Obj(),
wantStatus: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit fc10219

Please sign in to comment.