forked from kubernetes-sigs/node-feature-discovery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
1d277bf
commit f133c7c
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
) |