Skip to content

Commit 5292e9c

Browse files
wkingdqminh
authored andcommitted
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 <[email protected]>
1 parent 717af41 commit 5292e9c

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

config.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,33 @@ For POSIX platforms the `mounts` structure has the following fields:
156156
* **`env`** (array of strings, OPTIONAL) with the same semantics as [IEEE Std 1003.1-2008's `environ`][ieee-1003.1-2008-xbd-c8.1].
157157
* **`args`** (array of strings, REQUIRED) with similar semantics to [IEEE Std 1003.1-2008 `execvp`'s *argv*][ieee-1003.1-2008-xsh-exec].
158158
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*.
159+
160+
### <a name="configLinuxAndSolarisProcess" />Linux and Solaris Process
161+
162+
For POSIX-based systems (Linux and Solaris), the `process` object supports the following process-specific properties:
163+
159164
* **`rlimits`** (array of objects, OPTIONAL) allows setting resource limits for the process.
160165
Each entry has the following structure:
161166

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

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

169-
For Linux-based systems the process structure supports the following process-specific fields.
185+
For Linux-based systems, the `process` object supports the following process-specific properties.
170186

171187
* **`apparmorProfile`** (string, OPTIONAL) specifies the name of the AppArmor profile for the process.
172188
For more information about AppArmor, see [AppArmor documentation][apparmor].
@@ -837,7 +853,8 @@ Here is a full example `config.json` for reference.
837853
[mount.8]: http://man7.org/linux/man-pages/man8/mount.8.html
838854
[mount.8-filesystem-independent]: http://man7.org/linux/man-pages/man8/mount.8.html#FILESYSTEM-INDEPENDENT_MOUNT%20OPTIONS
839855
[mount.8-filesystem-specific]: http://man7.org/linux/man-pages/man8/mount.8.html#FILESYSTEM-SPECIFIC_MOUNT%20OPTIONS
840-
[setrlimit.2]: http://man7.org/linux/man-pages/man2/setrlimit.2.html
856+
[getrlimit.2]: http://man7.org/linux/man-pages/man2/getrlimit.2.html
857+
[getrlimit.3]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/getrlimit.html
841858
[stdin.3]: http://man7.org/linux/man-pages/man3/stdin.3.html
842859
[uts-namespace.7]: http://man7.org/linux/man-pages/man7/namespaces.7.html
843860
[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
@@ -45,7 +45,7 @@ type Process struct {
4545
// Capabilities are Linux capabilities that are kept for the process.
4646
Capabilities *LinuxCapabilities `json:"capabilities,omitempty" platform:"linux"`
4747
// Rlimits specifies rlimit options to apply to the process.
48-
Rlimits []LinuxRlimit `json:"rlimits,omitempty" platform:"linux"`
48+
Rlimits []POSIXRlimit `json:"rlimits,omitempty" platform:"linux,solaris"`
4949
// NoNewPrivileges controls whether additional privileges could be gained by processes in the container.
5050
NoNewPrivileges bool `json:"noNewPrivileges,omitempty" platform:"linux"`
5151
// ApparmorProfile specifies the apparmor profile for the container.
@@ -202,8 +202,8 @@ type LinuxIDMapping struct {
202202
Size uint32 `json:"size"`
203203
}
204204

205-
// LinuxRlimit type and restrictions
206-
type LinuxRlimit struct {
205+
// POSIXRlimit type and restrictions
206+
type POSIXRlimit struct {
207207
// Type of the rlimit to set
208208
Type string `json:"type"`
209209
// Hard is the hard limit for the specified type

0 commit comments

Comments
 (0)