Skip to content

Commit fe6833a

Browse files
committed
config: TolerateMissingHugePagesCgroupController -> TolerateMissingHugetlbController
Signed-off-by: Akihiro Suda <[email protected]>
1 parent b69d7bd commit fe6833a

6 files changed

Lines changed: 20 additions & 15 deletions

File tree

docs/config.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ version = 2
4545
# It generates a self-sign certificate unless the following x509_key_pair_streaming are both set.
4646
enable_tls_streaming = false
4747

48+
# tolerate_missing_hugetlb_controller if set to false will error out on create/update
49+
# container requests with huge page limits if the cgroup controller for hugepages is not present.
50+
# This helps with supporting Kubernetes <=1.18 out of the box. (default is `true`)
51+
tolerate_missing_hugetlb_controller = true
52+
4853
# ignore_image_defined_volumes ignores volumes defined by the image. Useful for better resource
4954
# isolation, security and early detection of issues in the mount configuration when using
5055
# ReadOnlyRootFilesystem since containers won't silently mount a temporary volume.

pkg/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,10 @@ type PluginConfig struct {
232232
// UnsetSeccompProfile is the profile containerd/cri will use If the provided seccomp profile is
233233
// unset (`""`) for a container (default is `unconfined`)
234234
UnsetSeccompProfile string `toml:"unset_seccomp_profile" json:"unsetSeccompProfile"`
235-
// TolerateMissingHugePagesCgroupController if set to false will error out on create/update
235+
// TolerateMissingHugetlbController if set to false will error out on create/update
236236
// container requests with huge page limits if the cgroup controller for hugepages is not present.
237237
// This helps with supporting Kubernetes <=1.18 out of the box. (default is `true`)
238-
TolerateMissingHugePagesCgroupController bool `toml:"tolerate_missing_hugepages_cgroup_controller" json:"tolerateMissingHugePagesCgroupController"`
238+
TolerateMissingHugetlbController bool `toml:"tolerate_missing_hugetlb_controller" json:"tolerateMissingHugetlbController"`
239239
// IgnoreImageDefinedVolumes ignores volumes defined by the image. Useful for better resource
240240
// isolation, security and early detection of issues in the mount configuration when using
241241
// ReadOnlyRootFilesystem since containers won't silently mount a temporary volume.

pkg/config/config_unix.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ func DefaultConfig() PluginConfig {
6363
},
6464
},
6565
},
66-
MaxConcurrentDownloads: 3,
67-
DisableProcMount: false,
68-
TolerateMissingHugePagesCgroupController: true,
69-
IgnoreImageDefinedVolumes: false,
66+
MaxConcurrentDownloads: 3,
67+
DisableProcMount: false,
68+
TolerateMissingHugetlbController: true,
69+
IgnoreImageDefinedVolumes: false,
7070
}
7171
}

pkg/containerd/opts/spec_unix.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ func WithSelinuxLabels(process, mount string) oci.SpecOpts {
408408
}
409409

410410
// WithResources sets the provided resource restrictions
411-
func WithResources(resources *runtime.LinuxContainerResources, tolerateMissingHugePagesCgroupController bool) oci.SpecOpts {
411+
func WithResources(resources *runtime.LinuxContainerResources, tolerateMissingHugetlbController bool) oci.SpecOpts {
412412
return func(ctx context.Context, client oci.Client, c *containers.Container, s *runtimespec.Spec) (err error) {
413413
if resources == nil {
414414
return nil
@@ -451,17 +451,17 @@ func WithResources(resources *runtime.LinuxContainerResources, tolerateMissingHu
451451
if limit != 0 {
452452
s.Linux.Resources.Memory.Limit = &limit
453453
}
454-
if isHugePagesControllerPresent() {
454+
if isHugetlbControllerPresent() {
455455
for _, limit := range hugepages {
456456
s.Linux.Resources.HugepageLimits = append(s.Linux.Resources.HugepageLimits, runtimespec.LinuxHugepageLimit{
457457
Pagesize: limit.PageSize,
458458
Limit: limit.Limit,
459459
})
460460
}
461461
} else {
462-
if !tolerateMissingHugePagesCgroupController {
462+
if !tolerateMissingHugetlbController {
463463
return errors.Errorf("huge pages limits are specified but hugetlb cgroup controller is missing. " +
464-
"Please set tolerate_missing_hugepages_cgroup_controller to `true` to ignore this error")
464+
"Please set tolerate_missing_hugetlb_controller to `true` to ignore this error")
465465
}
466466
logrus.Warn("hugetlb cgroup controller is absent. skipping huge pages limits")
467467
}
@@ -474,7 +474,7 @@ var (
474474
supportsHugetlb bool
475475
)
476476

477-
func isHugePagesControllerPresent() bool {
477+
func isHugetlbControllerPresent() bool {
478478
supportsHugetlbOnce.Do(func() {
479479
supportsHugetlb = false
480480
if IsCgroup2UnifiedMode() {

pkg/server/container_create_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func (c *criService) containerSpec(id string, sandboxID string, sandboxPid uint3
225225
if c.config.DisableCgroup {
226226
specOpts = append(specOpts, customopts.WithDisabledCgroups)
227227
} else {
228-
specOpts = append(specOpts, customopts.WithResources(config.GetLinux().GetResources(), c.config.TolerateMissingHugePagesCgroupController))
228+
specOpts = append(specOpts, customopts.WithResources(config.GetLinux().GetResources(), c.config.TolerateMissingHugetlbController))
229229
if sandboxConfig.GetLinux().GetCgroupParent() != "" {
230230
cgroupsPath := getCgroupsPath(sandboxConfig.GetLinux().GetCgroupParent(), id)
231231
specOpts = append(specOpts, oci.WithCgroup(cgroupsPath))

pkg/server/container_update_resources_unix.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (c *criService) updateContainerResources(ctx context.Context,
7373
return errors.Wrap(err, "failed to get container spec")
7474
}
7575
newSpec, err := updateOCILinuxResource(ctx, oldSpec, resources,
76-
c.config.TolerateMissingHugePagesCgroupController)
76+
c.config.TolerateMissingHugetlbController)
7777
if err != nil {
7878
return errors.Wrap(err, "failed to update resource in spec")
7979
}
@@ -134,7 +134,7 @@ func updateContainerSpec(ctx context.Context, cntr containerd.Container, spec *r
134134

135135
// updateOCILinuxResource updates container resource limit.
136136
func updateOCILinuxResource(ctx context.Context, spec *runtimespec.Spec, new *runtime.LinuxContainerResources,
137-
tolerateMissingHugePagesCgroupController bool) (*runtimespec.Spec, error) {
137+
tolerateMissingHugetlbController bool) (*runtimespec.Spec, error) {
138138
// Copy to make sure old spec is not changed.
139139
var cloned runtimespec.Spec
140140
if err := util.DeepCopy(&cloned, spec); err != nil {
@@ -143,7 +143,7 @@ func updateOCILinuxResource(ctx context.Context, spec *runtimespec.Spec, new *ru
143143
if cloned.Linux == nil {
144144
cloned.Linux = &runtimespec.Linux{}
145145
}
146-
if err := opts.WithResources(new, tolerateMissingHugePagesCgroupController)(ctx, nil, nil, &cloned); err != nil {
146+
if err := opts.WithResources(new, tolerateMissingHugetlbController)(ctx, nil, nil, &cloned); err != nil {
147147
return nil, errors.Wrap(err, "unable to set linux container resources")
148148
}
149149
return &cloned, nil

0 commit comments

Comments
 (0)