mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Merge pull request #59158 from derekwaynecarr/hugepage-feature
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. kubelet ignores hugepages if hugetlb is not enabled **What this PR does / why we need it**: if host os does not have the hugetlb cgroup mounted, kubelet does not error. **Which issue(s) this PR fixes** Fixes #58296 **Special notes for your reviewer**: for reference, the kubelet will just not report any hugepage resources. **Release note**: ```release-note NONE ```
This commit is contained in:
commit
ed36a727f9
@ -319,17 +319,18 @@ type subsystem interface {
|
||||
GetStats(path string, stats *libcontainercgroups.Stats) error
|
||||
}
|
||||
|
||||
// getSupportedSubsystems returns list of subsystems supported
|
||||
func getSupportedSubsystems() []subsystem {
|
||||
supportedSubsystems := []subsystem{
|
||||
&cgroupfs.MemoryGroup{},
|
||||
&cgroupfs.CpuGroup{},
|
||||
// getSupportedSubsystems returns a map of subsystem and if it must be mounted for the kubelet to function.
|
||||
func getSupportedSubsystems() map[subsystem]bool {
|
||||
supportedSubsystems := map[subsystem]bool{
|
||||
&cgroupfs.MemoryGroup{}: true,
|
||||
&cgroupfs.CpuGroup{}: true,
|
||||
}
|
||||
// not all hosts support hugetlb cgroup, and in the absent of hugetlb, we will fail silently by reporting no capacity.
|
||||
if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.HugePages) {
|
||||
supportedSubsystems = append(supportedSubsystems, &cgroupfs.HugetlbGroup{})
|
||||
supportedSubsystems[&cgroupfs.HugetlbGroup{}] = false
|
||||
}
|
||||
if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.SupportPodPidsLimit) {
|
||||
supportedSubsystems = append(supportedSubsystems, &cgroupfs.PidsGroup{})
|
||||
supportedSubsystems[&cgroupfs.PidsGroup{}] = true
|
||||
}
|
||||
return supportedSubsystems
|
||||
}
|
||||
@ -344,9 +345,14 @@ func getSupportedSubsystems() []subsystem {
|
||||
// but this is not possible with libcontainers Set() method
|
||||
// See https://github.com/opencontainers/runc/issues/932
|
||||
func setSupportedSubsystems(cgroupConfig *libcontainerconfigs.Cgroup) error {
|
||||
for _, sys := range getSupportedSubsystems() {
|
||||
for sys, required := range getSupportedSubsystems() {
|
||||
if _, ok := cgroupConfig.Paths[sys.Name()]; !ok {
|
||||
return fmt.Errorf("Failed to find subsystem mount for subsystem: %v", sys.Name())
|
||||
if required {
|
||||
return fmt.Errorf("Failed to find subsystem mount for required subsystem: %v", sys.Name())
|
||||
}
|
||||
// the cgroup is not mounted, but its not required so continue...
|
||||
glog.V(6).Infof("Unable to find subsystem mount for optional subsystem: %v", sys.Name())
|
||||
continue
|
||||
}
|
||||
if err := sys.Set(cgroupConfig.Paths[sys.Name()], cgroupConfig); err != nil {
|
||||
return fmt.Errorf("Failed to set config for supported subsystems : %v", err)
|
||||
@ -563,9 +569,14 @@ func (m *cgroupManagerImpl) ReduceCPULimits(cgroupName CgroupName) error {
|
||||
|
||||
func getStatsSupportedSubsystems(cgroupPaths map[string]string) (*libcontainercgroups.Stats, error) {
|
||||
stats := libcontainercgroups.NewStats()
|
||||
for _, sys := range getSupportedSubsystems() {
|
||||
for sys, required := range getSupportedSubsystems() {
|
||||
if _, ok := cgroupPaths[sys.Name()]; !ok {
|
||||
return nil, fmt.Errorf("Failed to find subsystem mount for subsystem: %v", sys.Name())
|
||||
if required {
|
||||
return nil, fmt.Errorf("Failed to find subsystem mount for required subsystem: %v", sys.Name())
|
||||
}
|
||||
// the cgroup is not mounted, but its not required so continue...
|
||||
glog.V(6).Infof("Unable to find subsystem mount for optional subsystem: %v", sys.Name())
|
||||
continue
|
||||
}
|
||||
if err := sys.GetStats(cgroupPaths[sys.Name()], stats); err != nil {
|
||||
return nil, fmt.Errorf("Failed to get stats for supported subsystems : %v", err)
|
||||
|
Loading…
Reference in New Issue
Block a user