This repository has been archived by the owner on Jul 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 237
/
lmctfy.proto
executable file
·610 lines (505 loc) · 17.3 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
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
// 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 NetworkSpec network = 5;
optional BlockIoSpec blockio = 12;
optional MonitoringSpec monitoring = 6;
optional FilesystemSpec filesystem = 7;
optional DeviceSpec device = 11;
// Virtual host environment.
optional VirtualHostSpec virtual_host = 10;
// Security spec.
optional SecuritySpec security_spec = 13;
// Next ID: 14
}
// 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;
message Console {
// The name of the slave pseudoterminal to be used. The format is that of
// the output of ptsname().
// TODO(vishnuk): Support both '/dev/pts/xx' and 'xx' as input. As of now it
// is expected to be just 'xx'.
optional string slave_pty = 1;
}
// UNIMPLEMENTED
optional Console console = 2;
// AppArmor profile name.
//
// TODO(xiaopanzhang): This should be in the ContainerSpec. However currently
// we don't checkpoint the ContainerSpec so the profile name which is given at
// "lmctfy create" time is not available at "lmctfy run" time. Remove this
// field as long as we have the checkpoint support in place.
optional string apparmor_profile = 3;
}
// 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;
// Runtime information.
optional RunSpec run_spec = 2;
}
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;
optional bool kmem_charge_usage = 11;
}
message BlockIoSpec {
// Block IO operations are only permitted on full devices, and not on
// partitions.
message Device {
optional int64 major = 1;
optional int64 minor = 2;
}
enum OpType {
READ = 1;
WRITE = 2;
}
enum LimitType {
// IOs can be limited by iops or bytes.
BYTES_PER_SECOND = 1;
IO_PER_SECOND = 2;
}
// Limits and thresholds only work with cfq scheduler.
// TODO(jnagal): Handle cases where the requested device is not setup to use
// cfq. Fail the request, or switch to cfq dynamically.
message DeviceLimit {
optional Device device = 1;
// limit is the desired fraction of device I/O time between 1 and 100.
// When used to express max limit, it can be bytes per second or iops
// per second, depending on the limit type.
optional uint64 limit = 2;
}
message DeviceLimitSet {
// Default weight applied to all devices.
optional uint32 default_limit = 1;
// Per-device weight overrides.
repeated DeviceLimit device_limits = 2;
}
message MaxLimit {
repeated DeviceLimit limits = 1;
optional OpType op_type = 2;
optional LimitType limit_type = 3;
}
message MaxLimitSet {
repeated MaxLimit max_limits = 1;
}
// Per-device overrides for the weight setting.
optional DeviceLimitSet device_limit_set = 1;
// Max allowed limits on each device. Thresholds can be applied on number of
// iops and bytes per second. Limits for read and write operations are
// specified separately.
optional MaxLimitSet max_device_limit_set = 2;
}
message NetworkSpec {
}
message MonitoringSpec {
// UNIMPLEMENTED
optional bool enable_perf_counters = 1;
}
message FilesystemSpec {
// UNIMPLEMENTED
optional uint64 fd_limit = 1;
// Path to root file filesystem. The container's root filesystem will point to
// this path.
// As of now, this option is supported only when a VirtualHost is specified.
optional string rootfs = 2;
// A set of file system entities that needs to be made available inside the
// Container.
// This option is supported only when a VirtualHost is specified.
// UNIMPLEMENTED.
optional Mounts mounts = 3;
}
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;
}
// Security spec for the container.
//
// We will support multiple security mechanisms in SecuritySpec. Notice that
// only one mechanism is effective at a time.
message SecuritySpec {
message AppArmorProfile {
// AppArmor's profiles live in /etc/apparmor.d/ and are loaded by the
// Apparmor kernel modules at system initialization. Process could apply
// these profiles by calling aa_change_onexec(2). Notice that AppArmor
// refers to profiles through the 'name' field defined in the profile file
// instead of the path to the profile file.
//
// This is a required field.
optional string name = 1;
}
// UNIMPLEMENTED.
optional AppArmorProfile apparmor_profile = 1;
}
// Statistics for a Container and its resource usage.
message ContainerStats {
// Commonly used resources
optional CpuStats cpu = 1;
optional MemoryStats memory = 2;
optional NetworkStats network = 4;
optional BlockIoStats blockio = 7;
optional MonitoringStats monitoring = 5;
optional FilesystemStats filesystem = 6;
// Next ID : 8
}
// 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 {
message Usage {
// CPU usage.
// Units: nanoseconds.
optional uint64 total = 1;
// CPU usage per cpu.
// Units: nanoseconds
repeated int64 per_cpu = 2;
// Time spent by tasks of the cgroup in user mode.
// Units: microseconds
optional int64 user = 3;
// Time spent by tasks of the cgroup in kernel mode.
// Units: microseconds
optional int64 system = 4;
}
optional Usage 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 hierarchical_data = 8;
optional int64 hierarchical_memory_limit = 9;
message NumaStats {
message NumaData {
message Stat {
message Node {
optional int32 level = 1;
optional int64 page_count = 2;
}
repeated Node node = 1;
optional int64 total_page_count = 2;
}
optional Stat total = 1;
optional Stat file = 2;
optional Stat anon = 3;
optional Stat unevictable = 4;
}
optional NumaData container_data = 1;
optional NumaData hierarchical_data = 2;
}
optional NumaStats numa = 10;
message IdlePageStats {
message Stats {
optional int32 age_in_secs = 1;
optional int64 clean = 2;
optional int64 dirty_file = 3;
optional int64 dirty_swap = 4;
}
repeated Stats stats = 1;
optional int64 scans = 2;
optional int64 stale = 3;
}
optional IdlePageStats idle_page = 11;
message CompressionSamplingStats {
optional int64 raw_size = 1;
optional int64 compressed_size = 2;
optional int64 fifo_overflow = 3;
}
optional CompressionSamplingStats compression_sampling = 12;
optional int64 fail_count = 13;
}
message BlockIoStats {
}
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;
}