Skip to content

Commit

Permalink
chore(qrm): nic allocation reactor use allocation identifier instead
Browse files Browse the repository at this point in the history
  • Loading branch information
luomingmeng committed Feb 8, 2025
1 parent b81427e commit 7ddb88f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions pkg/agent/qrm-plugins/network/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type AllocationInfo struct {

Egress uint32 `json:"egress"`
Ingress uint32 `json:"ingress"`
Identifier string `json:"identifier"`
NSName string `json:"ns_name"`
IfName string `json:"if_name"` // we do not support cross-nic bandwidth
NumaNodes machine.CPUSet `json:"numa_node"` // associated numa nodes of the socket connecting to the selected NIC
Expand Down Expand Up @@ -92,6 +93,7 @@ func (ai *AllocationInfo) Clone() *AllocationInfo {
AllocationMeta: *ai.AllocationMeta.Clone(),
Egress: ai.Egress,
Ingress: ai.Ingress,
Identifier: ai.Identifier,
NSName: ai.NSName,
IfName: ai.IfName,
NumaNodes: ai.NumaNodes.Clone(),
Expand Down
17 changes: 12 additions & 5 deletions pkg/agent/qrm-plugins/network/staticpolicy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,12 @@ func (p *StaticPolicy) GetTopologyAwareResources(_ context.Context,
}

nic := p.getNICByName(allocationInfo.IfName)
identifier := allocationInfo.Identifier
if identifier == "" {
// backup to use ifName and nic.NSName as identifier
identifier = getResourceIdentifier(nic.NSName, nic.Iface)

Check failure on line 400 in pkg/agent/qrm-plugins/network/staticpolicy/policy.go

View workflow job for this annotation

GitHub Actions / Lint

ineffectual assignment to identifier (ineffassign)
}

topologyAwareQuantityList := []*pluginapi.TopologyAwareQuantity{
{
ResourceValue: float64(allocationInfo.Egress),
Expand All @@ -402,7 +408,7 @@ func (p *StaticPolicy) GetTopologyAwareResources(_ context.Context,
Type: string(apinode.TopologyTypeNIC),
TopologyLevel: pluginapi.TopologyLevel_SOCKET,
Annotations: map[string]string{
apiconsts.ResourceAnnotationKeyResourceIdentifier: getResourceIdentifier(nic.NSName, allocationInfo.IfName),
apiconsts.ResourceAnnotationKeyResourceIdentifier: allocationInfo.Identifier,
apiconsts.ResourceAnnotationKeyNICNetNSName: nic.NSName,
},
},
Expand Down Expand Up @@ -679,11 +685,12 @@ func (p *StaticPolicy) Allocate(ctx context.Context,
newAllocation := &state.AllocationInfo{
AllocationMeta: commonstate.GenerateGenericContainerAllocationMeta(req,
commonstate.EmptyOwnerPoolName, qosLevel),
Egress: uint32(reqInt),
Ingress: uint32(reqInt),
IfName: selectedNIC.Iface,
Egress: uint32(reqInt),
Ingress: uint32(reqInt),
Identifier: getResourceIdentifier(selectedNIC.NSName, selectedNIC.Iface),
NSName: selectedNIC.NSName,
NumaNodes: siblingNUMAs,
IfName: selectedNIC.Iface,
NumaNodes: siblingNUMAs,
NetClassID: fmt.Sprintf("%d", netClassID),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (p nicPodAllocationWrapper) UpdateAllocation(pod *v1.Pod) error {
annotations = make(map[string]string)
}

annotations[apiconsts.PodAnnotationNICSelectionResultKey] = p.AllocationInfo.IfName
annotations[apiconsts.PodAnnotationNICSelectionResultKey] = p.AllocationInfo.Identifier
pod.SetAnnotations(annotations)

return nil
Expand Down

0 comments on commit 7ddb88f

Please sign in to comment.