Skip to content

Commit

Permalink
feat(qrm): add ResourceAnnotationKeyNICNetNSName
Browse files Browse the repository at this point in the history
  • Loading branch information
csfldf committed Apr 16, 2024
1 parent 756da4e commit cd665e1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
3 changes: 3 additions & 0 deletions pkg/agent/qrm-plugins/network/staticpolicy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
}
Expand Down Expand Up @@ -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{
Expand All @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions pkg/agent/qrm-plugins/network/staticpolicy/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
},
},
},
Expand Down Expand Up @@ -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: "",
},
},
{
Expand All @@ -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,
},
},
},
Expand All @@ -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: "",
},
},
{
Expand All @@ -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,
},
},
},
Expand Down

0 comments on commit cd665e1

Please sign in to comment.