Validate --cpuset-cpus, --cpuset-mems

Before this patch libcontainer badly errored out with `invalid
argument` or `numerical result out of range` while trying to write
to cpuset.cpus or cpuset.mems with an invalid value provided.
This patch adds validation to --cpuset-cpus and --cpuset-mems flag along with
validation based on system's available cpus/mems before starting a container.

Signed-off-by: Antonio Murdaca <runcom@linux.com>
Upstream-commit: 94464e3a5e1dce0f6b3e821f79fe193278f67dba
Component: engine
This commit is contained in:
Antonio Murdaca
2015-09-08 20:40:55 +02:00
parent 76ec29542e
commit 360eb92f7d
10 changed files with 303 additions and 7 deletions

View File

@ -827,4 +827,40 @@ var (
Description: "While trying to delete a container, there was an error trying to delete one of its volumes",
HTTPStatusCode: http.StatusInternalServerError,
})
// ErrorCodeInvalidCpusetCpus is generated when user provided cpuset CPUs
// are invalid.
ErrorCodeInvalidCpusetCpus = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "INVALIDCPUSETCPUS",
Message: "Invalid value %s for cpuset cpus.",
Description: "While verifying the container's 'HostConfig', CpusetCpus value was in an incorrect format",
HTTPStatusCode: http.StatusInternalServerError,
})
// ErrorCodeInvalidCpusetMems is generated when user provided cpuset mems
// are invalid.
ErrorCodeInvalidCpusetMems = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "INVALIDCPUSETMEMS",
Message: "Invalid value %s for cpuset mems.",
Description: "While verifying the container's 'HostConfig', CpusetMems value was in an incorrect format",
HTTPStatusCode: http.StatusInternalServerError,
})
// ErrorCodeNotAvailableCpusetCpus is generated when user provided cpuset
// CPUs aren't available in the container's cgroup.
ErrorCodeNotAvailableCpusetCpus = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "NOTAVAILABLECPUSETCPUS",
Message: "Requested CPUs are not available - requested %s, available: %s.",
Description: "While verifying the container's 'HostConfig', cpuset CPUs provided aren't available in the container's cgroup available set",
HTTPStatusCode: http.StatusInternalServerError,
})
// ErrorCodeNotAvailableCpusetMems is generated when user provided cpuset
// memory nodes aren't available in the container's cgroup.
ErrorCodeNotAvailableCpusetMems = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "NOTAVAILABLECPUSETMEMS",
Message: "Requested memory nodes are not available - requested %s, available: %s.",
Description: "While verifying the container's 'HostConfig', cpuset memory nodes provided aren't available in the container's cgroup available set",
HTTPStatusCode: http.StatusInternalServerError,
})
)