From cd665e1b0630f0df92b1be67460a2e037867985a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=81=A5=E4=BF=9E?= Date: Thu, 11 Apr 2024 15:54:05 +0800 Subject: [PATCH] feat(qrm): add ResourceAnnotationKeyNICNetNSName --- go.mod | 2 +- go.sum | 4 ++-- pkg/agent/qrm-plugins/network/staticpolicy/policy.go | 3 +++ pkg/agent/qrm-plugins/network/staticpolicy/policy_test.go | 5 +++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0c1e6324f..3c56c9711 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/google/cadvisor v0.44.2 github.com/google/uuid v1.3.0 github.com/klauspost/cpuid/v2 v2.2.6 - github.com/kubewharf/katalyst-api v0.4.1-0.20240409131259-e2612e3fc126 + github.com/kubewharf/katalyst-api v0.4.1-0.20240416065828-9edab1e2f1f1 github.com/montanaflynn/stats v0.7.1 github.com/opencontainers/runc v1.1.6 github.com/opencontainers/selinux v1.10.0 diff --git a/go.sum b/go.sum index 776d23bf8..126d676b7 100644 --- a/go.sum +++ b/go.sum @@ -554,8 +554,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kubewharf/katalyst-api v0.4.1-0.20240409131259-e2612e3fc126 h1:QdxIE9FXS9330/FausiLqpY+SOAOtgH+kX0CjluGN8w= -github.com/kubewharf/katalyst-api v0.4.1-0.20240409131259-e2612e3fc126/go.mod h1:Y2IeIorxQamF2a3oa0+URztl5QCSty6Jj3zD83R8J9k= +github.com/kubewharf/katalyst-api v0.4.1-0.20240416065828-9edab1e2f1f1 h1:wRSFa6v3ONl2D8ZsEyIj3O/I2euSqbwXgWsPdy7w6oY= +github.com/kubewharf/katalyst-api v0.4.1-0.20240416065828-9edab1e2f1f1/go.mod h1:Y2IeIorxQamF2a3oa0+URztl5QCSty6Jj3zD83R8J9k= github.com/kubewharf/kubelet v1.24.6-kubewharf.8 h1:2e89T/nZTgzaVhyRsZuwEdRk8V8kJXs4PRkgfeG4Ai4= github.com/kubewharf/kubelet v1.24.6-kubewharf.8/go.mod h1:MxbSZUx3wXztFneeelwWWlX7NAAStJ6expqq7gY2J3c= github.com/kyoh86/exportloopref v0.1.7/go.mod h1:h1rDl2Kdj97+Kwh4gdz3ujE7XHmH51Q0lUiZ1z4NLj8= diff --git a/pkg/agent/qrm-plugins/network/staticpolicy/policy.go b/pkg/agent/qrm-plugins/network/staticpolicy/policy.go index ef8a908bd..53ccc853d 100644 --- a/pkg/agent/qrm-plugins/network/staticpolicy/policy.go +++ b/pkg/agent/qrm-plugins/network/staticpolicy/policy.go @@ -350,6 +350,7 @@ func (p *StaticPolicy) GetTopologyAwareResources(_ context.Context, TopologyLevel: pluginapi.TopologyLevel_SOCKET, Annotations: map[string]string{ apiconsts.ResourceAnnotationKeyResourceIdentifier: getResourceIdentifier(nic.NSName, allocationInfo.IfName), + apiconsts.ResourceAnnotationKeyNICNetNSName: nic.NSName, }, }, } @@ -421,6 +422,7 @@ func (p *StaticPolicy) GetTopologyAwareAllocatableResources(_ context.Context, TopologyLevel: pluginapi.TopologyLevel_SOCKET, Annotations: map[string]string{ apiconsts.ResourceAnnotationKeyResourceIdentifier: resourceIdentifier, + apiconsts.ResourceAnnotationKeyNICNetNSName: iface.NSName, }, }) topologyAwareCapacityQuantityList = append(topologyAwareCapacityQuantityList, &pluginapi.TopologyAwareQuantity{ @@ -431,6 +433,7 @@ func (p *StaticPolicy) GetTopologyAwareAllocatableResources(_ context.Context, TopologyLevel: pluginapi.TopologyLevel_SOCKET, Annotations: map[string]string{ apiconsts.ResourceAnnotationKeyResourceIdentifier: resourceIdentifier, + apiconsts.ResourceAnnotationKeyNICNetNSName: iface.NSName, }, }) aggregatedAllocatableQuantity += general.MinUInt32(nicState.EgressState.Allocatable, nicState.IngressState.Allocatable) diff --git a/pkg/agent/qrm-plugins/network/staticpolicy/policy_test.go b/pkg/agent/qrm-plugins/network/staticpolicy/policy_test.go index 6a9b76256..be920c7a2 100644 --- a/pkg/agent/qrm-plugins/network/staticpolicy/policy_test.go +++ b/pkg/agent/qrm-plugins/network/staticpolicy/policy_test.go @@ -1351,6 +1351,7 @@ func TestGetTopologyAwareResources(t *testing.T) { Annotations: map[string]string{ // testEth0NSName is empty, so remove the prefix consts.ResourceAnnotationKeyResourceIdentifier: testEth0Name, + consts.ResourceAnnotationKeyNICNetNSName: "", }, }, }, @@ -1435,6 +1436,7 @@ func TestGetTopologyAwareAllocatableResources(t *testing.T) { Annotations: map[string]string{ // testEth0NSName is empty, so remove the prefix consts.ResourceAnnotationKeyResourceIdentifier: testEth0Name, + consts.ResourceAnnotationKeyNICNetNSName: "", }, }, { @@ -1445,6 +1447,7 @@ func TestGetTopologyAwareAllocatableResources(t *testing.T) { TopologyLevel: pluginapi.TopologyLevel_SOCKET, Annotations: map[string]string{ consts.ResourceAnnotationKeyResourceIdentifier: fmt.Sprintf("%s-%s", testEth2NSName, testEth2Name), + consts.ResourceAnnotationKeyNICNetNSName: testEth2NSName, }, }, }, @@ -1458,6 +1461,7 @@ func TestGetTopologyAwareAllocatableResources(t *testing.T) { Annotations: map[string]string{ // testEth0NSName is empty, so remove the prefix consts.ResourceAnnotationKeyResourceIdentifier: testEth0Name, + consts.ResourceAnnotationKeyNICNetNSName: "", }, }, { @@ -1468,6 +1472,7 @@ func TestGetTopologyAwareAllocatableResources(t *testing.T) { TopologyLevel: pluginapi.TopologyLevel_SOCKET, Annotations: map[string]string{ consts.ResourceAnnotationKeyResourceIdentifier: fmt.Sprintf("%s-%s", testEth2NSName, testEth2Name), + consts.ResourceAnnotationKeyNICNetNSName: testEth2NSName, }, }, },