Skip to content

Commit

Permalink
refine the implementation for qos configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
waynepeking348 committed Jan 16, 2024
1 parent 4da998a commit 1056e84
Show file tree
Hide file tree
Showing 15 changed files with 249 additions and 281 deletions.
2 changes: 1 addition & 1 deletion cmd/base/options/qos.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (o *QoSOptions) applyToExpandQoSEnhancement(c *generic.QoSConfiguration, po
enhancementMap[strings.TrimSpace(sList[0])] = strings.TrimSpace(sList[1])
}

c.SetExpandQoSEnhancementSelector(enhancementMap)
c.SetExpandQoSEnhancementKey(enhancementMap)
return nil
}

Expand Down
7 changes: 3 additions & 4 deletions pkg/agent/qrm-plugins/cpu/dynamicpolicy/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/uuid"
pluginapi "k8s.io/kubelet/pkg/apis/resourceplugin/v1alpha1"
utilfs "k8s.io/kubernetes/pkg/util/filesystem"

"github.com/stretchr/testify/require"

"github.com/kubewharf/katalyst-api/pkg/consts"
cpuconsts "github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/cpu/consts"
"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/cpu/dynamicpolicy/calculator"
Expand Down Expand Up @@ -679,7 +678,7 @@ func TestAllocate(t *testing.T) {
as.Nil(err)

if tc.enhancementDefaultValues != nil {
dynamicPolicy.qosConfig.EnhancementDefaultValues = tc.enhancementDefaultValues
dynamicPolicy.qosConfig.QoSEnhancementDefaultValues = tc.enhancementDefaultValues
}

resp, err := dynamicPolicy.Allocate(context.Background(), tc.req)
Expand Down Expand Up @@ -1095,7 +1094,7 @@ func TestGetTopologyHints(t *testing.T) {
as.Nil(err)

if tc.enhancementDefaultValues != nil {
dynamicPolicy.qosConfig.EnhancementDefaultValues = tc.enhancementDefaultValues
dynamicPolicy.qosConfig.QoSEnhancementDefaultValues = tc.enhancementDefaultValues
}

resp, err := dynamicPolicy.GetTopologyHints(context.Background(), tc.req)
Expand Down
1 change: 0 additions & 1 deletion pkg/agent/qrm-plugins/memory/dynamicpolicy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (

apiconsts "github.com/kubewharf/katalyst-api/pkg/consts"
"github.com/kubewharf/katalyst-api/pkg/plugins/skeleton"

"github.com/kubewharf/katalyst-core/cmd/katalyst-agent/app/agent"
"github.com/kubewharf/katalyst-core/cmd/katalyst-agent/app/agent/qrm"
"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/advisorsvc"
Expand Down
4 changes: 2 additions & 2 deletions pkg/agent/qrm-plugins/memory/dynamicpolicy/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ func TestAllocate(t *testing.T) {
as.Nil(err)

if tc.enhancementDefaultValues != nil {
dynamicPolicy.qosConfig.EnhancementDefaultValues = tc.enhancementDefaultValues
dynamicPolicy.qosConfig.QoSEnhancementDefaultValues = tc.enhancementDefaultValues
}

dynamicPolicy.enableMemoryAdvisor = true
Expand Down Expand Up @@ -1238,7 +1238,7 @@ func TestGetTopologyHints(t *testing.T) {
as.Nil(err)

if tc.enhancementDefaultValues != nil {
dynamicPolicy.qosConfig.EnhancementDefaultValues = tc.enhancementDefaultValues
dynamicPolicy.qosConfig.QoSEnhancementDefaultValues = tc.enhancementDefaultValues
}

resp, err := dynamicPolicy.GetTopologyHints(context.Background(), tc.req)
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/qrm-plugins/network/staticpolicy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ func (p *StaticPolicy) getNetClassID(podAnnotations map[string]string, podLevelN
return classID, nil
}

qosLevel, err := p.qosConfig.GetQoSLevel(podAnnotations)
qosLevel, err := p.qosConfig.GetQoSLevel(nil, podAnnotations)
if err != nil {
return 0, err
}
Expand Down
9 changes: 2 additions & 7 deletions pkg/agent/qrm-plugins/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func GetKatalystQoSLevelFromResourceReq(qosConf *generic.QoSConfiguration, req *
}

var getErr error
qosLevel, getErr = qosConf.GetQoSLevel(req.Annotations)
qosLevel, getErr = qosConf.GetQoSLevel(nil, req.Annotations)
if getErr != nil {
err = fmt.Errorf("resource type mismatches: %v", getErr)
return
Expand All @@ -91,12 +91,7 @@ func GetKatalystQoSLevelFromResourceReq(qosConf *generic.QoSConfiguration, req *
req.Annotations = make(map[string]string)
}
req.Annotations[apiconsts.PodAnnotationQoSLevelKey] = qosLevel
parsedAnnotations, err := qosConf.FilterQoSAndEnhancement(req.Annotations)
if err != nil {
err = fmt.Errorf("ParseKatalystAnnotations failed with error: %v", err)
return
}
req.Annotations = parsedAnnotations
req.Annotations = qosConf.FilterQoSAndEnhancementMap(req.Annotations)

if req.Labels == nil {
req.Labels = make(map[string]string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"
"google.golang.org/grpc"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -36,8 +37,6 @@ import (
"k8s.io/client-go/kubernetes/fake"
"k8s.io/kubelet/pkg/apis/resourceplugin/v1alpha1"

"github.com/stretchr/testify/require"

internalfake "github.com/kubewharf/katalyst-api/pkg/client/clientset/versioned/fake"
"github.com/kubewharf/katalyst-core/cmd/katalyst-agent/app/options"
"github.com/kubewharf/katalyst-core/pkg/agent/sysadvisor/metacache"
Expand Down
Loading

0 comments on commit 1056e84

Please sign in to comment.