talos/api/os/os.proto
Andrey Smirnov 5b7bea2471 feat: use grpc-proxy in apid
This replaces codegen version of apid proxying with
talos-systems/grpc-proxy based version. Proxying is transparent, it
doesn't require exact information about methods and response types. It
requires some common layout response to enhance it properly with node
metadata or errors.

There should be no signifcant changes to the API with the previous
version, but it's worth mentioning a few changes:

1. grpc.ClientConn is established just once per upstream (either local
service or remote apid instance).

2. When called without `-t` (`targets`), apid proxies immediately down
to local service skipping proxying to itself (as before), which results
in empty node metadata in response (before it had local node IP). Might
revert this later to proxy to itself (?).

3. Streaming APIs are now fully supported with multiple targets, but
message definition doesn't contain `ResponseMetadata`, so streaming APIs
are broken now with targets (needs a fix).

4. Errors are now returned as responses with `Error` field set in
`ResponseMetadata`, this requires client library update and `osctl` to
handle it properly.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2019-11-29 22:57:25 +03:00

187 lines
4.2 KiB
Protocol Buffer

syntax = "proto3";
package os;
option go_package = "github.com/talos-systems/talos/api/os";
option java_multiple_files = true;
option java_outer_classname = "OsApi";
option java_package = "com.os.api";
import "google/protobuf/empty.proto";
import "common/common.proto";
// The OS service definition.
//
// OS Service also implements all the API of Init Service
service OS {
rpc Containers(ContainersRequest) returns (ContainersReply);
rpc Dmesg(google.protobuf.Empty) returns (common.DataReply);
rpc Memory(google.protobuf.Empty) returns (MemInfoReply);
rpc Processes(google.protobuf.Empty) returns (ProcessesReply);
rpc Restart(RestartRequest) returns (RestartReply);
rpc Stats(StatsRequest) returns (StatsReply);
}
// rpc Containers
message ContainersRequest {
string namespace = 1;
// driver might be default "containerd" or "cri"
common.ContainerDriver driver = 2;
}
// The response message containing the requested containers.
message Container {
string namespace = 1;
string id = 2;
string image = 3;
uint32 pid = 4;
string status = 5;
string pod_id = 6;
string name = 7;
}
// The response message containing the requested containers.
message ContainerResponse {
common.ResponseMetadata metadata = 1;
repeated Container containers = 2;
}
message ContainersReply {
repeated ContainerResponse response = 1;
}
// rpc processes
message ProcessesRequest {}
message ProcessesReply {
repeated ProcessResponse response = 1;
}
message ProcessResponse {
common.ResponseMetadata metadata = 1;
repeated Process processes = 2;
}
message Process {
int32 pid = 1;
int32 ppid = 2;
string state = 3;
int32 threads = 4;
double cpu_time = 5;
uint64 virtual_memory = 6;
uint64 resident_memory = 7;
string command = 8;
string executable = 9;
string args = 10;
}
// rpc restart
// The request message containing the process to restart.
message RestartRequest {
string namespace = 1;
string id = 2;
// driver might be default "containerd" or "cri"
common.ContainerDriver driver = 3;
}
message RestartResponse {
common.ResponseMetadata metadata = 1;
}
// The response message containing the restart status.
message RestartReply {
repeated RestartResponse response = 1;
}
// rpc stats
// The request message containing the containerd namespace.
message StatsRequest {
string namespace = 1;
// driver might be default "containerd" or "cri"
common.ContainerDriver driver = 2;
}
// The response message containing the requested stats.
message StatsResponse {
common.ResponseMetadata metadata = 1;
repeated Stat stats = 2;
}
message StatsReply {
repeated StatsResponse response = 1;
}
// The response message containing the requested stat.
message Stat {
string namespace = 1;
string id = 2;
uint64 memory_usage = 4;
uint64 cpu_usage = 5;
string pod_id = 6;
string name = 7;
}
message MemInfoResponse {
common.ResponseMetadata metadata = 1;
MemInfo meminfo = 2;
}
message MemInfoReply {
repeated MemInfoResponse response = 1;
}
message MemInfo {
uint64 memtotal = 1;
uint64 memfree = 2;
uint64 memavailable = 3;
uint64 buffers = 4;
uint64 cached = 5;
uint64 swapcached = 6;
uint64 active = 7;
uint64 inactive = 8;
uint64 activeanon = 9;
uint64 inactiveanon = 10;
uint64 activefile = 11;
uint64 inactivefile = 12;
uint64 unevictable = 13;
uint64 mlocked = 14;
uint64 swaptotal = 15;
uint64 swapfree = 16;
uint64 dirty = 17;
uint64 writeback = 18;
uint64 anonpages = 19;
uint64 mapped = 20;
uint64 shmem = 21;
uint64 slab = 22;
uint64 sreclaimable = 23;
uint64 sunreclaim = 24;
uint64 kernelstack = 25;
uint64 pagetables = 26;
uint64 nfsunstable = 27;
uint64 bounce = 28;
uint64 writebacktmp = 29;
uint64 commitlimit = 30;
uint64 committedas = 31;
uint64 vmalloctotal = 32;
uint64 vmallocused = 33;
uint64 vmallocchunk = 34;
uint64 hardwarecorrupted = 35;
uint64 anonhugepages = 36;
uint64 shmemhugepages = 37;
uint64 shmempmdmapped = 38;
uint64 cmatotal = 39;
uint64 cmafree = 40;
uint64 hugepagestotal = 41;
uint64 hugepagesfree = 42;
uint64 hugepagesrsvd = 43;
uint64 hugepagessurp = 44;
uint64 hugepagesize = 45;
uint64 directmap4k = 46;
uint64 directmap2m = 47;
uint64 directmap1g = 48;
}