Skip to content

Commit

Permalink
Expose Topology manager scope
Browse files Browse the repository at this point in the history
As part of the Topology Aware Scheduling improvement, this update captures
the configured Topology manager scope in addition to the Topology manager policy.
Based on the value of both attribues a single string will be populated to the CRD.
The string value will be on of the following {SingleNUMANodeContainerLevel,
SingleNUMANodePodLevel, BestEffort, Restricted, None}

Change string literals to contants and fix naming

Co-Authored-by: Talor Itzhak <titzhak@redhat.com>
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
  • Loading branch information
swatisehgal and Tal-or committed Jul 9, 2021
1 parent 1d277bf commit f133c7c
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
35 changes: 35 additions & 0 deletions pkg/topologypolicy/topology-policy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package topologypolicy

// DetectTopologyPolicy returns TopologyManagerPolicy type which present
// both Topology manager policy and scope
func DetectTopologyPolicy(policy string, scope string) TopologyManagerPolicy {
k8sTmPolicy := K8sTopologyManagerPolicies(policy)
k8sTmScope := K8sTopologyManagerScopes(scope)
switch k8sTmPolicy {
case singleNumaNode:
if k8sTmScope == pod {
return SingleNumaPodScope
}
// default scope for single-numa-node
return SingleNumaContainerScope
case restricted:
return Restricted
case bestEffort:
return BestEffort
default:
return None
}
}
45 changes: 45 additions & 0 deletions pkg/topologypolicy/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package topologypolicy

// TopologyManagerPolicy constants which represent the current configuration
// for Topology manager policy and Topology manager scope in Kubelet config
type TopologyManagerPolicy string

const (
SingleNumaContainerScope TopologyManagerPolicy = "SingleNUMANodeContainerLevel"
SingleNumaPodScope TopologyManagerPolicy = "SingleNUMANodePodLevel"
Restricted TopologyManagerPolicy = "Restricted"
BestEffort TopologyManagerPolicy = "BestEffort"
None TopologyManagerPolicy = "None"
)

// K8sTopologyPolicies are resource allocation policies constants
type K8sTopologyManagerPolicies string

const (
singleNumaNode K8sTopologyManagerPolicies = "single-numa-node"
restricted K8sTopologyManagerPolicies = "restricted"
bestEffort K8sTopologyManagerPolicies = "best-effort"
none K8sTopologyManagerPolicies = "none"
)

// K8sTopologyScopes are constants which defines the granularity
// at which you would like resource alignment to be performed.
type K8sTopologyManagerScopes string

const (
pod K8sTopologyManagerScopes = "pod"
container K8sTopologyManagerScopes = "container"
)

0 comments on commit f133c7c

Please sign in to comment.