Hugepages to pod level supported resources

This commit is contained in:
Kevin Torres 2025-02-19 19:29:41 +00:00
parent 949abfc34f
commit e5020285fa

View File

@ -17,6 +17,8 @@ limitations under the License.
package resource package resource
import ( import (
"strings"
v1 "k8s.io/api/core/v1" v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/sets"
) )
@ -56,14 +58,14 @@ type PodResourcesOptions struct {
var supportedPodLevelResources = sets.New(v1.ResourceCPU, v1.ResourceMemory) var supportedPodLevelResources = sets.New(v1.ResourceCPU, v1.ResourceMemory)
func SupportedPodLevelResources() sets.Set[v1.ResourceName] { func SupportedPodLevelResources() sets.Set[v1.ResourceName] {
return supportedPodLevelResources return supportedPodLevelResources.Clone().Insert(v1.ResourceHugePagesPrefix)
} }
// IsSupportedPodLevelResources checks if a given resource is supported by pod-level // IsSupportedPodLevelResources checks if a given resource is supported by pod-level
// resource management through the PodLevelResources feature. Returns true if // resource management through the PodLevelResources feature. Returns true if
// the resource is supported. // the resource is supported.
func IsSupportedPodLevelResource(name v1.ResourceName) bool { func IsSupportedPodLevelResource(name v1.ResourceName) bool {
return supportedPodLevelResources.Has(name) return supportedPodLevelResources.Has(name) || strings.HasPrefix(string(name), v1.ResourceHugePagesPrefix)
} }
// IsPodLevelResourcesSet check if PodLevelResources pod-level resources are set. // IsPodLevelResourcesSet check if PodLevelResources pod-level resources are set.