Skip to content

Commit cb8df7b

Browse files
committed
config: Make rlimits POSIX-specific
This property was initially Linux-specific. 718f9f3 (minor narrative cleanup regarding config compatibility, 2017-01-30, #673) removed the Linux restriction, but the rlimit concept is from POSIX and Windows doesn't support it [1]. This commit adds new subsections for the POSIX-specific and Linux-specific process entries (to match the approach we currently use for process.user), and punts to POSIX for the Solaris values and compliance testing approach. If/when we get a Solaris-specific doc for valid values, we can replace the POSIX punt there, but we probably want to continue punting to POSIX for getrlimit(3)-based compliance testing. I've renamed the overly-specific LinuxRlimit to POSIXRlimit. We could use the generic Rlimit, but then we'd be stuck if/when Windows adds support for some rlimit-like thing that doesn't match up cleanly enough for us to use the POSIX structure. [1]: #835 (comment) Signed-off-by: W. Trevor King <wking@tremily.us>
1 parent e44e4eb commit cb8df7b

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

config.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,33 @@ For all platform-specific configuration values, the scope defined below in the [
145145
* **`env`** (array of strings, OPTIONAL) with the same semantics as [IEEE Std 1003.1-2001's `environ`][ieee-1003.1-2001-xbd-c8.1].
146146
* **`args`** (array of strings, REQUIRED) with similar semantics to [IEEE Std 1003.1-2001 `execvp`'s *argv*][ieee-1003.1-2001-xsh-exec].
147147
This specification extends the IEEE standard in that at least one entry is REQUIRED, and that entry is used with the same semantics as `execvp`'s *file*.
148-
* **`rlimits`** (array of objects, OPTIONAL) allows setting resource limits for a process inside the container.
148+
149+
### <a name="configLinuxAndSolarisProcess" />Linux and Solaris Process
150+
151+
For POSIX-based systems (Linux and Solaris), the `process` object supports the following process-specific properties:
152+
153+
* **`rlimits`** (array of objects, OPTIONAL) allows setting resource limits for the process.
149154
Each entry has the following structure:
150155

151-
* **`type`** (string, REQUIRED) - the platform resource being limited, for example on Linux as defined in the [setrlimit(2)][setrlimit.2] man page.
152-
* **`soft`** (uint64, REQUIRED) - the value of the limit enforced for the corresponding resource.
153-
* **`hard`** (uint64, REQUIRED) - the ceiling for the soft limit that could be set by an unprivileged process.
154-
Only a privileged process (e.g. under Linux: one with the CAP_SYS_RESOURCE capability) can raise a hard limit.
156+
* **`type`** (string, REQUIRED) the platform resource being limited.
157+
* Linux: valid values are defined in the [`getrlimit(2)`][setrlimit.2] man page, such as `RLIMIT_MSGQUEUE`.
158+
* Solaris: valid values are defined in the [`getrlimit(3)`][getrlimit.3] man page, such as `RLIMIT_CORE`.
159+
160+
The runtime MUST [generate an error](runtime.md#errors) for any values which cannot be mapped to a relevant kernel interface
161+
For each entry in `rlimits`, a [`getrlimit(3)`][getrlimit.3] on `type` MUST succeed.
162+
For the following properties, `rlim` refers to the status returned by the `getrlimit(3)` call.
163+
164+
* **`soft`** (uint64, REQUIRED) the value of the limit enforced for the corresponding resource.
165+
`rlim.rlim_cur` MUST match the configured value.
166+
* **`hard`** (uint64, REQUIRED) the ceiling for the soft limit that could be set by an unprivileged process.
167+
`rlim.rlim_max` MUST match the configured value.
168+
Only a privileged process (e.g. one with the `CAP_SYS_RESOURCE` capability) can raise a hard limit.
169+
170+
If `rlimits` contains duplicated entries with same `type`, the runtime MUST [generate an error](runtime.md#errors).
155171

156-
If `rlimits` contains duplicated entries with same `type`, the runtime MUST error out.
172+
### <a name="configLinuxProcess" />Linux Process
157173

158-
For Linux-based systems the process structure supports the following process-specific fields.
174+
For Linux-based systems, the `process` object supports the following process-specific properties.
159175

160176
* **`apparmorProfile`** (string, OPTIONAL) specifies the name of the AppArmor profile to be applied to processes in the container.
161177
For more information about AppArmor, see [AppArmor documentation][apparmor].
@@ -862,7 +878,8 @@ Here is a full example `config.json` for reference.
862878
[mount.8]: http://man7.org/linux/man-pages/man8/mount.8.html
863879
[mount.8-filesystem-independent]: http://man7.org/linux/man-pages/man8/mount.8.html#FILESYSTEM-INDEPENDENT_MOUNT%20OPTIONS
864880
[mount.8-filesystem-specific]: http://man7.org/linux/man-pages/man8/mount.8.html#FILESYSTEM-SPECIFIC_MOUNT%20OPTIONS
865-
[setrlimit.2]: http://man7.org/linux/man-pages/man2/setrlimit.2.html
881+
[getrlimit.2]: http://man7.org/linux/man-pages/man2/getrlimit.2.html
882+
[getrlimit.3]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/getrlimit.html
866883
[stdin.3]: http://man7.org/linux/man-pages/man3/stdin.3.html
867884
[uts-namespace.7]: http://man7.org/linux/man-pages/man7/namespaces.7.html
868885
[zonecfg.1m]: http://docs.oracle.com/cd/E86824_01/html/E54764/zonecfg-1m.html

specs-go/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type Process struct {
4747
// Capabilities are Linux capabilities that are kept for the process.
4848
Capabilities *LinuxCapabilities `json:"capabilities,omitempty" platform:"linux"`
4949
// Rlimits specifies rlimit options to apply to the process.
50-
Rlimits []LinuxRlimit `json:"rlimits,omitempty" platform:"linux"`
50+
Rlimits []POSIXRlimit `json:"rlimits,omitempty" platform:"linux,solaris"`
5151
// NoNewPrivileges controls whether additional privileges could be gained by processes in the container.
5252
NoNewPrivileges bool `json:"noNewPrivileges,omitempty" platform:"linux"`
5353
// ApparmorProfile specifies the apparmor profile for the container.
@@ -214,8 +214,8 @@ type LinuxIDMapping struct {
214214
Size uint32 `json:"size"`
215215
}
216216

217-
// LinuxRlimit type and restrictions
218-
type LinuxRlimit struct {
217+
// POSIXRlimit type and restrictions
218+
type POSIXRlimit struct {
219219
// Type of the rlimit to set
220220
Type string `json:"type"`
221221
// Hard is the hard limit for the specified type

0 commit comments

Comments
 (0)