Skip to content

Commit 738306f

Browse files
committed
proto: most of runtime done
Signed-off-by: Vincent Batts <[email protected]>
1 parent 8a33d07 commit 738306f

File tree

3 files changed

+213
-2
lines changed

3 files changed

+213
-2
lines changed

proto/config.proto

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
//package oci.config.bundle;
12
package oci;
23

3-
//import "config_user.proto";
4-
54
// Spec is the base configuration for the container. It specifies platform
65
// independent configuration.
76
message Spec {
@@ -19,6 +18,20 @@ message Spec {
1918
repeated MountPoint Mounts = 6;
2019
}
2120

21+
22+
// LinuxSpec is the full specification for linux containers.
23+
message LinuxSpec {
24+
optional Spec Spec = 1;
25+
// LinuxConfig is platform specific configuration for linux based containers.
26+
optional LinuxConfig LinuxConfig = 2;
27+
}
28+
29+
// LinuxConfig contains platform specific configuration for linux based containers.
30+
message LinuxConfig {
31+
// Capabilities are linux capabilities that are kept for the container.
32+
repeated string Capabilities = 1;
33+
}
34+
2235
// Platform specifies OS and arch information for the host system that the container
2336
// is created for.
2437
message Platform {

proto/runtime_config.proto

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//package oci.config.runtime;
2+
package oci;
3+
4+
import "runtime_config_linux.proto";
5+
6+
// RuntimeSpec is the generic runtime state information on a running container
7+
message RuntimeSpec {
8+
// Mounts is a mapping of names to mount configurations.
9+
// Which mounts will be mounted and where should be chosen with MountPoints
10+
// in Spec.
11+
repeated MountFieldEntry Mounts = 1;
12+
// Hooks are the commands run at various lifecycle events of the container.
13+
optional Hooks Hooks = 2;
14+
}
15+
16+
// LinuxRuntimeSpec is the full specification for linux containers.
17+
message LinuxRuntimeSpec {
18+
optional RuntimeSpec RuntimeSpec = 1;
19+
// LinuxRuntime is platform specific configuration for linux based containers.
20+
optional oci.LinuxRuntime Linux = 2;
21+
}
22+
23+
// MountFieldEntry is more backwards compatible protobuf associative map (than map<string, Mount>)
24+
message MountFieldEntry {
25+
required string key = 1;
26+
required Mount value = 2;
27+
}
28+
29+
// Mount specifies a mount for a container
30+
message Mount {
31+
// Type specifies the mount kind.
32+
optional string Type = 1;
33+
// Source specifies the source path of the mount. In the case of bind mounts on
34+
// linux based systems this would be the file on the host.
35+
optional string Source = 2;
36+
// Options are fstab style mount options.
37+
repeated string Options = 3;
38+
}
39+
40+
// Hook specifies a command that is run at a particular event in the lifecycle of a container
41+
message Hook {
42+
optional string Path = 1;
43+
repeated string Args = 2;
44+
repeated string Env = 3;
45+
}
46+
47+
// Hooks for container setup and teardown
48+
message Hooks {
49+
// Prestart is a list of hooks to be run before the container process is executed.
50+
// On Linux, they are run after the container namespaces are created.
51+
repeated Hook Prestart = 1;
52+
// Poststop is a list of hooks to be run after the container process exits.
53+
repeated Hook Poststop = 2;
54+
}

proto/runtime_config_linux.proto

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
package oci;
2+
3+
// LinuxStateDirectory holds the container's state information
4+
message DefaultState {
5+
// TODO(vbatts) not as elegant in some ways, but there is not a concept of const here
6+
optional string Directory = 1 [default = "/run/opencontainer/containers"];
7+
}
8+
9+
// LinuxRuntime hosts the Linux-only runtime information
10+
message LinuxRuntime {
11+
// UIDMapping specifies user mappings for supporting user namespaces on linux.
12+
repeated IDMapping UIDMapping = 1;
13+
// GIDMapping specifies group mappings for supporting user namespaces on linux.
14+
repeated IDMapping GIDMapping = 2;
15+
// Rlimits specifies rlimit options to apply to the container's process.
16+
repeated Rlimit Rlimits = 3;
17+
// Sysctl are a set of key value pairs that are set for the container on start
18+
repeated StringStringEntry Sysctl = 4;
19+
// Resources contain cgroup information for handling resource constraints
20+
// for the container
21+
optional Resources Resources = 5;
22+
// TODO(vbatts) add the rest ..
23+
}
24+
25+
// IDMapping specifies UID/GID mappings
26+
message IDMapping {
27+
// HostID is the UID/GID of the host user or group
28+
optional int32 HostID = 1;
29+
// ContainerID is the UID/GID of the container's user or group
30+
optional int32 ContainerID = 2;
31+
// Size is the length of the range of IDs mapped between the two namespaces
32+
optional int32 Size = 3;
33+
}
34+
35+
// Rlimit type and restrictions
36+
message Rlimit {
37+
// Type of the rlimit to set
38+
optional string Type = 1;
39+
// Hard is the hard limit for the specified type
40+
optional uint64 Hard = 2;
41+
// Soft is the soft limit for the specified type
42+
optional uint64 Soft = 3;
43+
}
44+
45+
// StringStringEntry is more backwards compatible protobuf associative map (than map<string, Mount>)
46+
message StringStringEntry {
47+
required string key = 1;
48+
required string value = 2;
49+
}
50+
51+
// Resources has container runtime resource constraints
52+
message Resources {
53+
// DisableOOMKiller disables the OOM killer for out of memory conditions
54+
optional bool DisableOOMKiller = 1;
55+
// Memory restriction configuration
56+
optional Memory Memory = 2;
57+
// CPU resource restriction configuration
58+
optional CPU CPU = 3;
59+
// Task resource restriction configuration.
60+
optional Pids Pids = 4;
61+
// BlockIO restriction configuration
62+
optional BlockIO BlockIO = 5;
63+
// Hugetlb limit (in bytes)
64+
repeated HugepageLimit HugepageLimits = 6;
65+
// Network restriction configuration
66+
optional Network Network = 7;
67+
}
68+
69+
// Memory for Linux cgroup 'memory' resource management
70+
message Memory {
71+
// Memory limit (in bytes)
72+
optional int64 Limit = 1;
73+
// Memory reservation or soft_limit (in bytes)
74+
optional int64 Reservation = 2;
75+
// Total memory usage (memory + swap); set `-1' to disable swap
76+
optional int64 Swap = 3;
77+
// Kernel memory limit (in bytes)
78+
optional int64 Kernel = 4;
79+
// How aggressive the kernel will swap memory pages. Range from 0 to 100. Set -1 to use system default
80+
optional int64 Swappiness = 5;
81+
}
82+
83+
// CPU for Linux cgroup 'cpu' resource management
84+
message CPU {
85+
// CPU shares (relative weight vs. other cgroups with cpu shares)
86+
optional int64 Shares = 1;
87+
// CPU hardcap limit (in usecs). Allowed cpu time in a given period
88+
optional int64 Quota = 2;
89+
// CPU period to be used for hardcapping (in usecs). 0 to use system default
90+
optional int64 Period = 3;
91+
// How many time CPU will use in realtime scheduling (in usecs)
92+
optional int64 RealtimeRuntime = 4;
93+
// CPU period to be used for realtime scheduling (in usecs)
94+
optional int64 RealtimePeriod = 5;
95+
// CPU to use within the cpuset
96+
optional string Cpus = 6;
97+
// MEM to use within the cpuset
98+
optional string Mems = 7;
99+
}
100+
101+
// Pids for Linux cgroup 'pids' resource management (Linux 4.3)
102+
message Pids {
103+
// Maximum number of PIDs. A value < 0 implies "no limit".
104+
optional int64 Limit = 1;
105+
}
106+
107+
// BlockIO for Linux cgroup 'blockio' resource management
108+
message BlockIO {
109+
// Specifies per cgroup weight, range is from 10 to 1000
110+
optional int64 Weight = 1;
111+
// Weight per cgroup per device, can override BlkioWeight
112+
optional string WeightDevice = 2;
113+
// IO read rate limit per cgroup per device, bytes per second
114+
optional string ThrottleReadBpsDevice = 3;
115+
// IO write rate limit per cgroup per divice, bytes per second
116+
optional string ThrottleWriteBpsDevice = 4;
117+
// IO read rate limit per cgroup per device, IO per second
118+
optional string ThrottleReadIOpsDevice = 5;
119+
// IO write rate limit per cgroup per device, IO per second
120+
optional string ThrottleWriteIOpsDevice = 6;
121+
}
122+
123+
// HugepageLimit structure corresponds to limiting kernel hugepages
124+
message HugepageLimit {
125+
optional string Pagesize = 1;
126+
optional int32 Limit = 2;
127+
}
128+
129+
// Network identification and priority configuration
130+
message Network {
131+
// Set class identifier for container's network packets
132+
optional string ClassID = 1;
133+
// Set priority of network traffic for container
134+
repeated InterfacePriority Priorities = 2;
135+
}
136+
137+
// InterfacePriority for network interfaces
138+
message InterfacePriority {
139+
// Name is the name of the network interface
140+
optional string Name = 1;
141+
// Priority for the interface
142+
optional int64 Priority = 2;
143+
}
144+

0 commit comments

Comments
 (0)