forked from google/lmctfy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
lmctfy.proto
executable file
·537 lines (440 loc) · 14.8 KB
/
lmctfy.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
// Copyright 2014 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto2";
package containers.lmctfy;
import "include/virtual_host.proto";
// Specifies what resources to isolate (and how they should be isolated) on a
// container. Used for container creation and updates.
message ContainerSpec {
// UID of the requested container owner. If this field is missing it is
// assumed to be the same as the caller at creation time.
optional int64 owner = 1;
// The GID of the requested owner's group. If this field is missing it is
// assumed to be the same as the caller at creation time.
optional int64 owner_group = 8;
// The limit on allowed children for this container.
optional int64 children_limit = 9;
// Commonly used resources.
optional CpuSpec cpu = 2;
optional MemorySpec memory = 3;
optional DiskIoSpec diskio = 4;
optional NetworkSpec network = 5;
optional MonitoringSpec monitoring = 6;
optional FilesystemSpec filesystem = 7;
optional DeviceSpec device = 11;
// Virtual host environment.
optional VirtualHostSpec virtual_host = 10;
// Next ID: 12
}
// Specification for supported notification events.
message EventSpec {
// Event triggered when the specified container runs out of memory.
message Oom {
}
optional Oom oom = 1;
// Event triggered when the specified container crossed the specified memory
// usage threshold.
message MemoryThreshold {
// The threshold in bytes.
optional int64 usage = 1;
}
optional MemoryThreshold memory_threshold = 2;
// UNIMPLEMENTED.
// Event triggered when the specified container is empty (it has no processes
// or threads). This may occur due to movement of threads or exiting of
// processes.
message ContainerEmpty {
}
optional ContainerEmpty container_empty = 3;
}
message RunSpec {
// How to handle the file descriptors for the new process.
enum FdPolicy {
// Invalid policy.
UNKNOWN = 0;
// Run the command with all file descriptors inherited from the parent
// process.
INHERIT = 1;
// Run the command with all file descriptors detached from the parent
// process (redirected to /dev/null).
DETACHED = 2;
}
// If missing defaults to INHERIT.
optional FdPolicy fd_policy = 1;
}
// VirtualHostSpec configures a host environment for the container.
// An empty VirtualHostSpec is invalid. Currently VirtualHostSpec can only be
// specified for top-level containers.
// Adding an empty VirtualHostSpec enables process, ipc, and mount isolation, if
// enabled on the host kernel.
message VirtualHostSpec {
// UNIMPLEMENTED
// Hostname visible to the tasks running inside container.
optional string virtual_hostname = 1;
// The command to be used for init. A default init is used if this is not
// provided.
message Init {
repeated string init_argv = 1;
}
optional Init init = 2;
// Network setup in the Virtual Host.
optional Network network = 3;
// TODO(vmarmol): Add a MountSpec, we enable mount isolation, but don't have a
// way to specify mounts just yet.
}
enum SchedulingLatency {
// No latency guarantee.
BEST_EFFORT = 1;
// Guarantee on forward progress.
NORMAL = 2;
// Low-latency access for latency-sensitive loads. Default.
PRIORITY = 3;
// Extremely low-latency access for latency-critical loads.
PREMIER = 4;
}
message CpuSpec {
// CPU scheduling latency guarantee to provide for the container. Default
// scheduling latency is NORMAL. Note that scheduling latency cannot be
// updated.
optional SchedulingLatency scheduling_latency = 1;
// The amount of CPU requested.
// Units: CPU milliseconds per second.
optional uint64 limit = 2;
// The amount of CPU after which the container's usage will be throttled.
// Units: CPU milliseconds per second.
optional uint64 max_limit = 3;
// Mask of CPU cores on which this container will be allowed to run. If not
// specified, inherits the parent's mask.
message Mask {
repeated uint64 data = 1;
}
optional Mask mask = 4;
}
message MemorySpec {
// Relative eviction priority in range of 0 - 10000. Higher value means
// higher priority and less likely to get evicted. Default value is 5000.
optional int32 eviction_priority = 1;
// The amount of memory requested. Default is unlimited (-1).
// Units: bytes.
optional int64 limit = 2;
// UNIMPLEMENTED
// The hard limit on the amount of memory that can be used. Going over "limit"
// may decrease the priority of memory requests, going over "max_limit" OOMs
// the container. When it is not specified, defaults to "limit".
// Units: bytes.
optional int64 max_limit = 3;
// The amount of guaranteed memory. Default is 0.
// Units: bytes.
optional int64 reservation = 4;
// UNIMPLEMENTED
// Absolute path.
optional string hugetlbfs_path = 5;
// UNIMPLEMENTED
message TmpfsSpec {
// Absolute path.
repeated string path = 1;
}
optional TmpfsSpec tmpfs = 6;
// The amount of swap space requested. Default is unlimited (-1).
// Units: bytes.
optional int64 swap_limit = 7;
// The sampling ratio for idle anon memory
optional int32 compression_sampling_ratio = 8;
// Time (in seconds) after which a page is considered cold.
optional int32 stale_page_age = 9;
message Dirty {
// Either both ratios or both limits should be set. A mixture of ratios
// and limits is incorrect, as is just one ratio or limit.
optional int32 ratio = 1;
optional int32 limit = 2;
optional int32 background_ratio = 3;
optional int32 background_limit = 4;
};
optional Dirty dirty = 10;
}
message DiskIoSpec {
message DiskConfig {
// Logical name used as identifier by kernel (eg. sda)
optional string logical_disk_name = 1;
// Requested fraction of disk time [Range: 0 to 100].
optional int32 disk_time_fraction = 2;
// Portion of disk time fraction reserved for high-priority I/O.
// Should be less than disk_time_fraction [ Range: 0 to disk_time_fraction].
optional int32 priority_disk_time_fraction = 3;
// Maximum fraction of disk time that can be used. Going over this limit
// would throttle IO. [ Range: 0 to 100]. Total disk time used (priority +
// normal) is counted. There is no maximum limit by default.
optional int32 max_disk_time_fraction = 4;
}
// UNIMPLEMENTED
message DiskSpec {
repeated DiskConfig config = 1;
}
optional DiskSpec disk_spec = 1;
enum Priority {
// Only use shared disk time. Not allowed to reserve any time slices.
DEFAULT = 1;
// Can reserve time slices. Not allowed to use front-of-line pass.
// Time slice reservations can vary per disk.
PRODUCTION = 2;
// Allowed to use reserved time slices and front-of-line pass.
// Reservations and priority can vary per disk.
PRIORITY = 3;
}
// UNIMPLEMENTED
optional Priority priority = 2;
}
message NetworkSpec {
}
message MonitoringSpec {
// UNIMPLEMENTED
optional bool enable_perf_counters = 1;
}
message FilesystemSpec {
// UNIMPLEMENTED
optional uint64 fd_limit = 1;
}
message DeviceSpec {
// Controls devices that are allowed to be accessible inside a container.
// root container has all devices accessible. Child container
// inherits its parent's device access setting.
// A typical pattern is to add a rule to deny all device access and add
// the ones that are required by the container.
enum DeviceType {
// Character device.
DEVICE_CHAR = 0;
// Block device.
DEVICE_BLOCK = 1;
// All device types.
// When DEVICE_ALL is specified, access type is ignored and all devices
// are either denied or allowed depending on the permission.
DEVICE_ALL = 2;
}
enum DeviceAccess {
// Access type can be any combination of read, write, and mknod.
READ = 1;
WRITE = 2;
MKNOD = 3;
}
enum DevicePermission {
// Permission for a device can either be allowed or denied inside
// a container.
ALLOW = 1;
DENY = 2;
}
message DeviceRestrictions {
optional DevicePermission permission = 1;
optional DeviceType type = 2;
repeated DeviceAccess access = 3;
// Missing major/minor number implies any device.
optional int64 major = 4;
optional int64 minor = 5;
}
message DeviceRestrictionsSet {
repeated DeviceRestrictions restrictions = 1;
}
optional DeviceRestrictionsSet restrictions_set = 1;
}
// TODO(vmarmol): Design and narrow this spec down.
// Machine-wide configurations that are not specific to any container.
message MachineSpec {
}
// Known and supported cgroup hierarchies.
enum CgroupHierarchy {
CGROUP_UNKNOWN = 0;
CGROUP_CPU = 1;
CGROUP_CPUACCT = 2;
CGROUP_CPUSET = 3;
CGROUP_FREEZER = 4;
CGROUP_IO = 5;
CGROUP_JOB = 6;
CGROUP_MEMORY = 7;
CGROUP_NET = 8;
CGROUP_PERF_EVENT = 9;
CGROUP_RLIMIT = 10;
CGROUP_DEVICE = 11;
}
// A mount point for a set of cgroup subsystems.
message CgroupMount {
// The full path to where the cgroups should be mounted.
optional string mount_path = 1;
// Type of the cgroup subsystems to be mounted at this point.
repeated CgroupHierarchy hierarchy = 2;
}
// Describes how to setup lmctfy at machine boot.
message InitSpec {
optional CpuInitSpec cpu = 1;
optional MemoryInitSpec memory = 2;
optional DiskIoInitSpec diskio = 3;
optional NetworkInitSpec network = 4;
optional MonitoringInitSpec monitoring = 5;
optional FilesystemInitSpec filesystem = 6;
// The mount locations of the cgroup hierarchies.
repeated CgroupMount cgroup_mount = 7;
}
message CpuInitSpec {
}
message MemoryInitSpec {
}
message DiskIoInitSpec {
}
message NetworkInitSpec {
}
message MonitoringInitSpec {
}
message FilesystemInitSpec {
}
// Statistics for a Container and its resource usage.
message ContainerStats {
// Commonly used resources
optional CpuStats cpu = 1;
optional MemoryStats memory = 2;
optional DiskIoStats diskio = 3;
optional NetworkStats network = 4;
optional MonitoringStats monitoring = 5;
optional FilesystemStats filesystem = 6;
}
// Type of scheduling histograms exported by kernel.
enum CpuHistogramType {
// Total amount of time a task is runnable.
SERVE = 1;
// Amount of time a task is scheduled on a cpu in a single stretch.
ONCPU = 2;
// Amount of time a task is sleeping or blocking.
SLEEP = 3;
// Amount of time waiting in runnable state behind a task from the same
// cgroup.
QUEUE_SELF = 4;
// Amount of time waiting in runnable state behind a task from a different
// cgroup.
QUEUE_OTHER = 5;
};
message HistogramMap {
message Bucket {
required int32 bucket = 1;
required int64 value = 2;
}
required CpuHistogramType type = 1;
repeated Bucket stat = 2;
}
message ThrottlingData {
// Number of periods with throttling active.
optional int64 periods = 1;
// Number of periods when the container hit its throttling limit.
optional int64 throttled_periods = 2;
// Aggregate time the container was throttled for.
// Units: nanoseconds.
optional int64 throttled_time = 3;
}
message CpuStats {
// CPU usage.
// Units: nanoseconds.
optional uint64 usage = 1;
// CPU load, average number of runnable threads.
optional int32 load = 2;
// CPU throttling stats.
optional ThrottlingData throttling_data = 3;
// CPU scheduling histograms.
repeated HistogramMap histograms = 4;
}
message MemoryStats {
// Memory limit, equivalent to "limit" in MemorySpec.
// Units: Bytes.
optional int64 limit = 1;
// Effective memory limit, this may be different from "limit" above if the
// parent has less than "limit" memory available.
// Units: Bytes.
optional int64 effective_limit = 2;
// Reserved memory.
// Units: Bytes.
optional int64 reservation = 3;
// Usage statistics.
// Current memory usage, this includes all memory regardless of when it was
// accessed.
// Units: Bytes.
optional int64 usage = 4;
// Max memory usage observed in container's lifetime.
// Units: Bytes.
optional int64 max_usage = 5;
// The amount of working set memory, this includes recently accessed memory,
// dirty memory, and kernel memmory. Working set is <= "usage".
// Units: Bytes.
optional int64 working_set = 6;
message MemoryData {
optional int64 cache = 1;
optional int64 rss = 2;
optional int64 rss_huge = 3;
optional int64 mapped_file = 4;
optional int64 pgpgin = 5;
optional int64 pgpgout = 6;
optional int64 pgfault = 7;
optional int64 pgmajfault = 8;
optional int64 dirty = 9;
optional int64 writeback = 10;
optional int64 inactive_anon = 11;
optional int64 active_anon = 12;
optional int64 inactive_file = 13;
optional int64 active_file = 14;
optional int64 unevictable = 15;
message THP {
optional int64 fault_alloc = 1;
optional int64 fault_fallback = 2;
optional int64 collapse_alloc = 3;
optional int64 collapse_alloc_failed = 4;
optional int64 split = 5;
}
optional THP thp = 16;
message Kernel {
optional int64 memory = 1;
optional int64 slab_memory = 2;
optional int64 stack_memory = 3;
optional int64 pgtable_memory = 4;
optional int64 vmalloc_memory = 5;
optional int64 misc_memory = 6;
optional int64 targeted_slab_memory = 7;
optional int64 compressed_memory = 8;
}
optional Kernel kernel = 17;
optional Kernel kernel_noncharged = 18;
optional int64 compressed_pool_pages = 19;
optional int64 compressed_stored_pages = 20;
optional int64 compressed_reject_compress_poor = 21;
optional int64 zswap_zsmalloc_fail = 22;
optional int64 zswap_kmemcache_fail = 23;
optional int64 zswap_duplicate_entry = 24;
optional int64 zswap_compressed_pages = 25;
optional int64 zswap_decompressed_pages = 26;
optional int64 zswap_compression_nsec = 27;
optional int64 zswap_decompression_nsec = 28;
}
// Stats about memory specific to this container
optional MemoryData container_data = 7;
// Stats about memory for this container and all of its subcontainers
optional MemoryData total_data = 8;
optional int64 hierarchical_memory_limit = 9;
}
message DiskIoStats {
}
message NetworkStats {
}
message MonitoringStats {
}
message FilesystemStats {
// Number of fds in use.
optional int64 fd_usage = 1;
// Max fd usage observed in container's lifetime.
optional int64 fd_max_usage = 2;
// Number of times container failed to get an fd because it hit the limit.
optional int64 fd_fail_count = 3;
}