Skip to content

Commit

Permalink
noderesourcetopology: refactor to align to the left
Browse files Browse the repository at this point in the history
Align to the left the loops consuming the topology policies
- which now is at most one for better readability.
No intended change in behavior.

Signed-off-by: Francesco Romani <fromani@redhat.com>
  • Loading branch information
ffromani committed Jan 25, 2023
1 parent e718dc4 commit 3c58cc1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
17 changes: 9 additions & 8 deletions pkg/noderesourcetopology/filter.go
Expand Up @@ -213,15 +213,16 @@ func (tm *TopologyMatch) Filter(ctx context.Context, cycleState *framework.Cycle
}

policyName := nodeTopology.TopologyPolicies[0]
if handler, ok := tm.filterHandlers[topologyv1alpha1.TopologyManagerPolicy(policyName)]; ok {
if status := handler(pod, nodeTopology.Zones, nodeInfo); status != nil {
tm.nrtCache.NodeMaybeOverReserved(nodeName, pod)
return status
}
} else {
klog.V(5).InfoS("Policy handler not found", "policy", policyName)
handler, ok := tm.filterHandlers[topologyv1alpha1.TopologyManagerPolicy(policyName)]
if !ok {
klog.V(4).InfoS("Policy handler not found", "policy", policyName)
return nil
}
return nil
status := handler(pod, nodeTopology.Zones, nodeInfo)
if status != nil {
tm.nrtCache.NodeMaybeOverReserved(nodeName, pod)
}
return status
}

// subtractFromNUMA finds the correct NUMA ID's resources and subtract them from `nodes`.
Expand Down
13 changes: 7 additions & 6 deletions pkg/noderesourcetopology/score.go
Expand Up @@ -80,14 +80,15 @@ func (tm *TopologyMatch) Score(ctx context.Context, state *framework.CycleState,
}

policyName := nodeTopology.TopologyPolicies[0]
if handler, ok := tm.scoringHandlers[topologyv1alpha1.TopologyManagerPolicy(policyName)]; ok {
// calculates the fraction of requested to capacity per each numa-node.
// return the numa-node with the minimal score as the node's total score
return handler(pod, nodeTopology.Zones)
} else {
handler, ok := tm.scoringHandlers[topologyv1alpha1.TopologyManagerPolicy(policyName)]
if !ok {
klog.V(4).InfoS("policy handler not found", "policy", policyName)
return 0, nil
}
return 0, nil

// calculates the fraction of requested to capacity per each numa-node.
// return the numa-node with the minimal score as the node's total score
return handler(pod, nodeTopology.Zones)
}

func (tm *TopologyMatch) ScoreExtensions() framework.ScoreExtensions {
Expand Down

0 comments on commit 3c58cc1

Please sign in to comment.