warden-protocol 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +6 -0
- data/README.md +13 -0
- data/Rakefile +40 -0
- data/lib/warden/protocol.rb +4 -0
- data/lib/warden/protocol/base.rb +168 -0
- data/lib/warden/protocol/buffer.rb +69 -0
- data/lib/warden/protocol/build.sh +13 -0
- data/lib/warden/protocol/message.rb +50 -0
- data/lib/warden/protocol/pb.rb +497 -0
- data/lib/warden/protocol/pb/copy_in.proto +35 -0
- data/lib/warden/protocol/pb/copy_out.proto +39 -0
- data/lib/warden/protocol/pb/create.proto +65 -0
- data/lib/warden/protocol/pb/destroy.proto +33 -0
- data/lib/warden/protocol/pb/echo.proto +26 -0
- data/lib/warden/protocol/pb/error.proto +19 -0
- data/lib/warden/protocol/pb/info.proto +95 -0
- data/lib/warden/protocol/pb/limit_bandwidth.proto +30 -0
- data/lib/warden/protocol/pb/limit_disk.proto +70 -0
- data/lib/warden/protocol/pb/limit_memory.proto +34 -0
- data/lib/warden/protocol/pb/link.proto +40 -0
- data/lib/warden/protocol/pb/list.proto +25 -0
- data/lib/warden/protocol/pb/message.proto +36 -0
- data/lib/warden/protocol/pb/net_in.proto +39 -0
- data/lib/warden/protocol/pb/net_out.proto +35 -0
- data/lib/warden/protocol/pb/ping.proto +24 -0
- data/lib/warden/protocol/pb/resource_limits.proto +30 -0
- data/lib/warden/protocol/pb/run.proto +29 -0
- data/lib/warden/protocol/pb/spawn.proto +37 -0
- data/lib/warden/protocol/pb/stop.proto +40 -0
- data/lib/warden/protocol/pb/stream.proto +41 -0
- data/lib/warden/protocol/version.rb +7 -0
- data/spec/base_spec.rb +150 -0
- data/spec/buffer_spec.rb +65 -0
- data/spec/copy_in_spec.rb +51 -0
- data/spec/copy_out_spec.rb +56 -0
- data/spec/create_spec.rb +70 -0
- data/spec/destroy_spec.rb +36 -0
- data/spec/echo_spec.rb +42 -0
- data/spec/error_spec.rb +33 -0
- data/spec/info_spec.rb +122 -0
- data/spec/limit_bandwidth_spec.rb +57 -0
- data/spec/limit_disk_spec.rb +103 -0
- data/spec/limit_memory_spec.rb +47 -0
- data/spec/link_spec.rb +67 -0
- data/spec/list_spec.rb +41 -0
- data/spec/net_in_spec.rb +57 -0
- data/spec/net_out_spec.rb +47 -0
- data/spec/ping_spec.rb +32 -0
- data/spec/resource_limits_spec.rb +84 -0
- data/spec/run_spec.rb +79 -0
- data/spec/spawn_spec.rb +55 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/stop_spec.rb +46 -0
- data/spec/stream_spec.rb +65 -0
- data/spec/support/examples/wrappable_reply.rb +26 -0
- data/spec/support/examples/wrappable_request.rb +26 -0
- data/spec/support/helper.rb +122 -0
- data/spec/support/matchers.rb +22 -0
- data/warden-protocol.gemspec +21 -0
- metadata +166 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
// Copies files into a container.
|
2
|
+
//
|
3
|
+
// File permissions and symbolic links are be preserved, while hard links
|
4
|
+
// are materialized. If the source path contains a trailing `/`, only the
|
5
|
+
// contents of the directory will be copied. Otherwise, the outermost
|
6
|
+
// directory, along with its contents, will be copied. The unprivileged
|
7
|
+
// user inside the container is made owner of the resulting files.
|
8
|
+
//
|
9
|
+
// ### Request
|
10
|
+
//
|
11
|
+
// * `handle`: Container handle.
|
12
|
+
// * `src_path`: Path on the host to copy from.
|
13
|
+
// * `dst_path`: Path in the container to copy to.
|
14
|
+
//
|
15
|
+
// ### Response
|
16
|
+
//
|
17
|
+
// Empty.
|
18
|
+
//
|
19
|
+
// ### Errors
|
20
|
+
//
|
21
|
+
// > **TODO**
|
22
|
+
//
|
23
|
+
// ### Definition
|
24
|
+
//
|
25
|
+
|
26
|
+
package warden;
|
27
|
+
|
28
|
+
message CopyInRequest {
|
29
|
+
required string handle = 1;
|
30
|
+
required string src_path = 2;
|
31
|
+
required string dst_path = 3;
|
32
|
+
}
|
33
|
+
|
34
|
+
message CopyInResponse {
|
35
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
// Copies files out of a container.
|
2
|
+
//
|
3
|
+
// File permissions and symbolic links are be preserved, while hard links
|
4
|
+
// are materialized. If the source path contains a trailing `/`, only the
|
5
|
+
// contents of the directory will be copied. Otherwise, the outermost
|
6
|
+
// directory, along with its contents, will be copied.
|
7
|
+
//
|
8
|
+
// By default, the files on the host will be owned by root.
|
9
|
+
// If the `owner` field in the request is specified (in the form of `USER:GROUP`),
|
10
|
+
// the resulting files and directories will be owned by this user and group.
|
11
|
+
//
|
12
|
+
// ### Request
|
13
|
+
//
|
14
|
+
// * `handle`: Container handle.
|
15
|
+
// * `src_path`: Path in the container to copy from.
|
16
|
+
// * `dst_path`: Path on the host to copy to.
|
17
|
+
//
|
18
|
+
// ### Response
|
19
|
+
//
|
20
|
+
// Empty.
|
21
|
+
//
|
22
|
+
// ### Errors
|
23
|
+
//
|
24
|
+
// > **TODO**
|
25
|
+
//
|
26
|
+
// ### Definition
|
27
|
+
//
|
28
|
+
|
29
|
+
package warden;
|
30
|
+
|
31
|
+
message CopyOutRequest {
|
32
|
+
required string handle = 1;
|
33
|
+
required string src_path = 2;
|
34
|
+
required string dst_path = 3;
|
35
|
+
optional string owner = 4;
|
36
|
+
}
|
37
|
+
|
38
|
+
message CopyOutResponse {
|
39
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
// Creates a new container.
|
2
|
+
//
|
3
|
+
// ### Request
|
4
|
+
//
|
5
|
+
// All parameters are optional.
|
6
|
+
//
|
7
|
+
// * `bind_mounts`: Contains the paths that should be mounted in the
|
8
|
+
// container's filesystem. The `src_path` field for every bind mount holds the
|
9
|
+
// path as seen from the host, where the `dst_path` field holds the path as
|
10
|
+
// seem from the container.
|
11
|
+
//
|
12
|
+
// * `grace_time`: Can be used to specify how long a container can go
|
13
|
+
// unreferenced by any client connection. After this time, the container will
|
14
|
+
// automatically be destroyed. If not specified, the container will be
|
15
|
+
// subject to the globally configured grace time.
|
16
|
+
//
|
17
|
+
// * `handle`: If specified, its value must be used to refer to the
|
18
|
+
// container in future requests. If it is not specified,
|
19
|
+
// warden uses its internal container ID as the container handle.
|
20
|
+
//
|
21
|
+
// > **TODO**: `network` and `rootfs`
|
22
|
+
//
|
23
|
+
// ### Response
|
24
|
+
//
|
25
|
+
// The `handle` field contains the handle that must be used to refer to the
|
26
|
+
// container in future request. It is the same as the `handle` field in the
|
27
|
+
// request, if it was passed.
|
28
|
+
//
|
29
|
+
// ### Errors
|
30
|
+
//
|
31
|
+
// * When the `handle`, if specified, is already taken.
|
32
|
+
// * When one of the `bind_mount` paths does not exist.
|
33
|
+
// * When resource allocations fail (subnet, user ID, etc).
|
34
|
+
//
|
35
|
+
// ### Definition
|
36
|
+
//
|
37
|
+
|
38
|
+
package warden;
|
39
|
+
|
40
|
+
message CreateRequest {
|
41
|
+
message BindMount {
|
42
|
+
enum Mode {
|
43
|
+
RO = 0;
|
44
|
+
RW = 1;
|
45
|
+
}
|
46
|
+
|
47
|
+
required string src_path = 1;
|
48
|
+
required string dst_path = 2;
|
49
|
+
required Mode mode = 3;
|
50
|
+
}
|
51
|
+
|
52
|
+
repeated BindMount bind_mounts = 1;
|
53
|
+
|
54
|
+
optional uint32 grace_time = 2;
|
55
|
+
|
56
|
+
optional string handle = 3;
|
57
|
+
|
58
|
+
optional string network = 4;
|
59
|
+
|
60
|
+
optional string rootfs = 5;
|
61
|
+
}
|
62
|
+
|
63
|
+
message CreateResponse {
|
64
|
+
required string handle = 1;
|
65
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
// Destroys a container.
|
2
|
+
//
|
3
|
+
// When a container is destroyed, its resource allocations are released,
|
4
|
+
// its filesystem is removed, and all references to its handle are removed.
|
5
|
+
//
|
6
|
+
// All resources that have been acquired during the lifetime of the container are released.
|
7
|
+
// Examples of these resources are its subnet, its UID, and ports that were redirected to the container.
|
8
|
+
//
|
9
|
+
// > **TODO** Link to list of resources that can be acquired during the lifetime of a container.
|
10
|
+
//
|
11
|
+
// ### Request
|
12
|
+
//
|
13
|
+
// * `handle`: Container handle.
|
14
|
+
//
|
15
|
+
// ### Response
|
16
|
+
//
|
17
|
+
// Empty.
|
18
|
+
//
|
19
|
+
// ### Errors
|
20
|
+
//
|
21
|
+
// * When `handle` does not refer to a container.
|
22
|
+
//
|
23
|
+
// ### Definition
|
24
|
+
//
|
25
|
+
|
26
|
+
package warden;
|
27
|
+
|
28
|
+
message DestroyRequest {
|
29
|
+
required string handle = 1;
|
30
|
+
}
|
31
|
+
|
32
|
+
message DestroyResponse {
|
33
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
// Echoes a message.
|
2
|
+
//
|
3
|
+
// ### Request
|
4
|
+
//
|
5
|
+
// * `message`: Message to echo.
|
6
|
+
//
|
7
|
+
// ### Response
|
8
|
+
//
|
9
|
+
// * `message`: Echoed message.
|
10
|
+
//
|
11
|
+
// ### Errors
|
12
|
+
//
|
13
|
+
// None.
|
14
|
+
//
|
15
|
+
// ### Definition
|
16
|
+
//
|
17
|
+
|
18
|
+
package warden;
|
19
|
+
|
20
|
+
message EchoRequest {
|
21
|
+
required string message = 1;
|
22
|
+
}
|
23
|
+
|
24
|
+
message EchoResponse {
|
25
|
+
required string message = 1;
|
26
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
// This is only a response.
|
2
|
+
// If an error occurs while executing a request, it is captured and returned as an `ErrorResponse`.
|
3
|
+
//
|
4
|
+
// ### Response
|
5
|
+
//
|
6
|
+
// * `message`: Error message.
|
7
|
+
// * `data`: Unused.
|
8
|
+
// * `backtrace`: Unused.
|
9
|
+
//
|
10
|
+
// ### Definition
|
11
|
+
//
|
12
|
+
|
13
|
+
package warden;
|
14
|
+
|
15
|
+
message ErrorResponse {
|
16
|
+
optional string message = 2;
|
17
|
+
optional string data = 4;
|
18
|
+
repeated string backtrace = 3;
|
19
|
+
}
|
@@ -0,0 +1,95 @@
|
|
1
|
+
// Returns information about a container.
|
2
|
+
//
|
3
|
+
// ### Request
|
4
|
+
//
|
5
|
+
// * `handle`: Container handle.
|
6
|
+
//
|
7
|
+
// ### Response
|
8
|
+
//
|
9
|
+
// * `state`: Either "active" or "stopped".
|
10
|
+
// * `events`: List of events that occurred for the container. It currently includes only "oom" (Out Of Memory) event if it occurred.
|
11
|
+
// * `host_ip`: IP address of the host side of the container's virtual ethernet pair.
|
12
|
+
// * `container_ip`: IP address of the container side of the container's virtual ethernet pair.
|
13
|
+
// * `container_path`: Path to the directory holding the container's files (both its control scripts and filesystem).
|
14
|
+
// * `job_ids`: List of running jobs.
|
15
|
+
//
|
16
|
+
// > **TODO** Describe different types of stats.
|
17
|
+
//
|
18
|
+
// ### Errors
|
19
|
+
//
|
20
|
+
// * When `handle` does not refer to a container.
|
21
|
+
//
|
22
|
+
// ### Definition
|
23
|
+
//
|
24
|
+
|
25
|
+
package warden;
|
26
|
+
|
27
|
+
message InfoRequest {
|
28
|
+
required string handle = 1;
|
29
|
+
}
|
30
|
+
|
31
|
+
message InfoResponse {
|
32
|
+
message MemoryStat {
|
33
|
+
optional uint64 cache = 1;
|
34
|
+
optional uint64 rss = 2;
|
35
|
+
optional uint64 mapped_file = 3;
|
36
|
+
optional uint64 pgpgin = 4;
|
37
|
+
optional uint64 pgpgout = 5;
|
38
|
+
optional uint64 swap = 6;
|
39
|
+
optional uint64 pgfault = 7;
|
40
|
+
optional uint64 pgmajfault = 8;
|
41
|
+
optional uint64 inactive_anon = 9;
|
42
|
+
optional uint64 active_anon = 10;
|
43
|
+
optional uint64 inactive_file = 11;
|
44
|
+
optional uint64 active_file = 12;
|
45
|
+
optional uint64 unevictable = 13;
|
46
|
+
optional uint64 hierarchical_memory_limit = 14;
|
47
|
+
optional uint64 hierarchical_memsw_limit = 15;
|
48
|
+
optional uint64 total_cache = 16;
|
49
|
+
optional uint64 total_rss = 17;
|
50
|
+
optional uint64 total_mapped_file = 18;
|
51
|
+
optional uint64 total_pgpgin = 19;
|
52
|
+
optional uint64 total_pgpgout = 20;
|
53
|
+
optional uint64 total_swap = 21;
|
54
|
+
optional uint64 total_pgfault = 22;
|
55
|
+
optional uint64 total_pgmajfault = 23;
|
56
|
+
optional uint64 total_inactive_anon = 24;
|
57
|
+
optional uint64 total_active_anon = 25;
|
58
|
+
optional uint64 total_inactive_file = 26;
|
59
|
+
optional uint64 total_active_file = 27;
|
60
|
+
optional uint64 total_unevictable = 28;
|
61
|
+
}
|
62
|
+
|
63
|
+
message CpuStat {
|
64
|
+
optional uint64 usage = 1; // Nanoseconds
|
65
|
+
optional uint64 user = 2; // Hz (USER_HZ specifically)
|
66
|
+
optional uint64 system = 3; // Hz
|
67
|
+
}
|
68
|
+
|
69
|
+
message DiskStat {
|
70
|
+
optional uint64 bytes_used = 1;
|
71
|
+
optional uint64 inodes_used = 2;
|
72
|
+
}
|
73
|
+
|
74
|
+
message BandwidthStat {
|
75
|
+
optional uint64 in_rate = 1;
|
76
|
+
optional uint64 in_burst = 2;
|
77
|
+
optional uint64 out_rate = 3;
|
78
|
+
optional uint64 out_burst = 4;
|
79
|
+
}
|
80
|
+
|
81
|
+
optional string state = 10;
|
82
|
+
|
83
|
+
repeated string events = 20;
|
84
|
+
|
85
|
+
optional string host_ip = 30;
|
86
|
+
optional string container_ip = 31;
|
87
|
+
optional string container_path = 32;
|
88
|
+
|
89
|
+
optional MemoryStat memory_stat = 40;
|
90
|
+
optional CpuStat cpu_stat = 41;
|
91
|
+
optional DiskStat disk_stat = 42;
|
92
|
+
optional BandwidthStat bandwidth_stat = 43;
|
93
|
+
|
94
|
+
repeated uint64 job_ids = 44;
|
95
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
// Limits the network bandwidth for a container.
|
2
|
+
//
|
3
|
+
// ### Request
|
4
|
+
//
|
5
|
+
// > **TODO**
|
6
|
+
//
|
7
|
+
// ### Response
|
8
|
+
//
|
9
|
+
// > **TODO**
|
10
|
+
//
|
11
|
+
// ### Errors
|
12
|
+
//
|
13
|
+
// > **TODO**
|
14
|
+
//
|
15
|
+
// ### Definition
|
16
|
+
//
|
17
|
+
|
18
|
+
package warden;
|
19
|
+
|
20
|
+
message LimitBandwidthRequest {
|
21
|
+
required string handle = 1;
|
22
|
+
|
23
|
+
required uint64 rate = 2; // Bandwidth rate in byte(s)/sec
|
24
|
+
required uint64 burst = 3; // Allow burst size in byte(s)
|
25
|
+
}
|
26
|
+
|
27
|
+
message LimitBandwidthResponse {
|
28
|
+
required uint64 rate = 1; // Bandwidth rate in byte(s)/sec
|
29
|
+
required uint64 burst = 2; // Allow burst size in byte(s)
|
30
|
+
}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
// Limits the disk usage for a container.
|
2
|
+
//
|
3
|
+
// The disk limits that are set by this command only have effect for the container's unprivileged user.
|
4
|
+
// Files/directories created by its privileged user are not subject to these limits.
|
5
|
+
//
|
6
|
+
// > **TODO** Link to page explaining how disk management works.
|
7
|
+
//
|
8
|
+
// ### Request
|
9
|
+
//
|
10
|
+
// * `handle`: Container handle.
|
11
|
+
// * `block_soft`: New soft block limit.
|
12
|
+
// * `block_hard`: New hard block limit.
|
13
|
+
// * `inode_soft`: New soft inode limit.
|
14
|
+
// * `inode_hard`: New hard inode limit.
|
15
|
+
// * `byte_soft`: New soft block limit specified in bytes. Only has effect when `block_soft` is not specified.
|
16
|
+
// * `byte_hard`: New hard block limit specified in bytes. Only has effect when `block_hard` is not specified.
|
17
|
+
//
|
18
|
+
// ### Response
|
19
|
+
//
|
20
|
+
// * `block_soft`: Soft block limit.
|
21
|
+
// * `block_hard`: Hard block limit.
|
22
|
+
// * `inode_soft`: Soft inode limit.
|
23
|
+
// * `inode_hard`: Hard inode limit.
|
24
|
+
// * `byte_soft`: Soft block limit specified in bytes.
|
25
|
+
// * `byte_hard`: Hard block limit specified in bytes.
|
26
|
+
//
|
27
|
+
// ### Errors
|
28
|
+
//
|
29
|
+
// > **TODO**
|
30
|
+
//
|
31
|
+
// ### Definition
|
32
|
+
//
|
33
|
+
|
34
|
+
package warden;
|
35
|
+
|
36
|
+
message LimitDiskRequest {
|
37
|
+
required string handle = 1;
|
38
|
+
|
39
|
+
optional uint64 block_limit = 10; // Alias for `block_hard`
|
40
|
+
optional uint64 block = 11; // Alias for `block_hard`
|
41
|
+
optional uint64 block_soft = 12;
|
42
|
+
optional uint64 block_hard = 13;
|
43
|
+
|
44
|
+
optional uint64 inode_limit = 20; // Alias for `inode_hard`
|
45
|
+
optional uint64 inode = 21; // Alias for `inode_hard`
|
46
|
+
optional uint64 inode_soft = 22;
|
47
|
+
optional uint64 inode_hard = 23;
|
48
|
+
|
49
|
+
optional uint64 byte_limit = 30; // Alias for `byte_hard`
|
50
|
+
optional uint64 byte = 31; // Alias for `byte_hard`
|
51
|
+
optional uint64 byte_soft = 32;
|
52
|
+
optional uint64 byte_hard = 33;
|
53
|
+
}
|
54
|
+
|
55
|
+
message LimitDiskResponse {
|
56
|
+
optional uint64 block_limit = 10; // Alias for `block_hard`
|
57
|
+
optional uint64 block = 11; // Alias for `block_hard`
|
58
|
+
optional uint64 block_soft = 12;
|
59
|
+
optional uint64 block_hard = 13;
|
60
|
+
|
61
|
+
optional uint64 inode_limit = 20; // Alias for `inode_hard`
|
62
|
+
optional uint64 inode = 21; // Alias for `inode_hard`
|
63
|
+
optional uint64 inode_soft = 22;
|
64
|
+
optional uint64 inode_hard = 23;
|
65
|
+
|
66
|
+
optional uint64 byte_limit = 30; // Alias for `byte_hard`
|
67
|
+
optional uint64 byte = 31; // Alias for `byte_hard`
|
68
|
+
optional uint64 byte_soft = 32;
|
69
|
+
optional uint64 byte_hard = 33;
|
70
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
// > **TODO** Link to page explaining how memory limits works.
|
2
|
+
//
|
3
|
+
// ### Request
|
4
|
+
//
|
5
|
+
// The field `limit_in_bytes` is optional.
|
6
|
+
// When it is not specified, the memory usage limit will not be changed.
|
7
|
+
// When it is specified, but not a multiple of the page size,
|
8
|
+
// it is rounded up to the nearest multiple of the page size (the default page size is 4K).
|
9
|
+
//
|
10
|
+
// * `handle`: Container handle.
|
11
|
+
// * `limit_in_bytes`: New memory usage limit in bytes.
|
12
|
+
//
|
13
|
+
// ### Response
|
14
|
+
//
|
15
|
+
// * `limit_in_bytes`: Memory usage limit in bytes.
|
16
|
+
//
|
17
|
+
// ### Errors
|
18
|
+
//
|
19
|
+
// > **TODO**
|
20
|
+
//
|
21
|
+
// ### Definition
|
22
|
+
//
|
23
|
+
|
24
|
+
package warden;
|
25
|
+
|
26
|
+
message LimitMemoryRequest {
|
27
|
+
required string handle = 1;
|
28
|
+
|
29
|
+
optional uint64 limit_in_bytes = 2;
|
30
|
+
}
|
31
|
+
|
32
|
+
message LimitMemoryResponse {
|
33
|
+
optional uint64 limit_in_bytes = 1;
|
34
|
+
}
|