mirror of
https://github.com/containers/podman.git
synced 2025-06-26 04:46:57 +08:00
Merge pull request #18052 from sstosh/resource-rootless
Do not display the resource limits warning message
This commit is contained in:
@ -5,12 +5,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
"github.com/containers/common/pkg/cgroups"
|
"github.com/containers/common/pkg/cgroups"
|
||||||
"github.com/containers/common/pkg/sysinfo"
|
"github.com/containers/common/pkg/sysinfo"
|
||||||
"github.com/containers/podman/v4/pkg/rootless"
|
"github.com/containers/podman/v4/pkg/rootless"
|
||||||
"github.com/containers/podman/v4/pkg/specgen"
|
"github.com/containers/podman/v4/pkg/specgen"
|
||||||
"github.com/containers/podman/v4/utils"
|
"github.com/containers/podman/v4/utils"
|
||||||
|
"github.com/opencontainers/runtime-spec/specs-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Verify resource limits are sanely set when running on cgroup v1.
|
// Verify resource limits are sanely set when running on cgroup v1.
|
||||||
@ -19,13 +21,16 @@ func verifyContainerResourcesCgroupV1(s *specgen.SpecGenerator) ([]string, error
|
|||||||
|
|
||||||
sysInfo := sysinfo.New(true)
|
sysInfo := sysinfo.New(true)
|
||||||
|
|
||||||
if s.ResourceLimits != nil && rootless.IsRootless() {
|
// If ResourceLimits is nil, return without warning
|
||||||
s.ResourceLimits = nil
|
resourceNil := &specgen.SpecGenerator{}
|
||||||
warnings = append(warnings, "Resource limits are not supported and ignored on cgroups V1 rootless systems")
|
resourceNil.ResourceLimits = &specs.LinuxResources{}
|
||||||
|
if s.ResourceLimits == nil || reflect.DeepEqual(s.ResourceLimits, resourceNil.ResourceLimits) {
|
||||||
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.ResourceLimits == nil {
|
// Cgroups V1 rootless system does not support Resource limits
|
||||||
return warnings, nil
|
if rootless.IsRootless() {
|
||||||
|
return []string{"Resource limits are not supported and ignored on cgroups V1 rootless systems"}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.ResourceLimits.Unified != nil {
|
if s.ResourceLimits.Unified != nil {
|
||||||
|
@ -237,7 +237,6 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test "podman kube --network" {
|
@test "podman kube --network" {
|
||||||
skip_if_rootless_cgroupsv1 "Test will never be supported, see #17582."
|
|
||||||
TESTDIR=$PODMAN_TMPDIR/testdir
|
TESTDIR=$PODMAN_TMPDIR/testdir
|
||||||
mkdir -p $TESTDIR
|
mkdir -p $TESTDIR
|
||||||
echo "$testYaml" | sed "s|TESTDIR|${TESTDIR}|g" > $PODMAN_TMPDIR/test.yaml
|
echo "$testYaml" | sed "s|TESTDIR|${TESTDIR}|g" > $PODMAN_TMPDIR/test.yaml
|
||||||
|
Reference in New Issue
Block a user