Merge execution and container service
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
parent
ac3cc32dbc
commit
5a86eae247
8 changed files with 3912 additions and 4315 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,115 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package containerd.v1;
|
||||
|
||||
import "google/protobuf/empty.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
|
||||
service ContainerService {
|
||||
rpc Get(GetContainerRequest) returns (GetContainerResponse);
|
||||
rpc Update(UpdateContainerRequest) returns (google.protobuf.Empty);
|
||||
rpc Pause(PauseContainerRequest) returns (google.protobuf.Empty);
|
||||
rpc Resume(ResumeContainerRequest) returns (google.protobuf.Empty);
|
||||
rpc Start(StartContainerRequest) returns (google.protobuf.Empty);
|
||||
|
||||
rpc StartProcess(StartProcessRequest) returns (StartProcessResponse);
|
||||
rpc GetProcess(GetProcessRequest) returns (GetProcessResponse);
|
||||
rpc SignalProcess(SignalProcessRequest) returns (google.protobuf.Empty);
|
||||
rpc DeleteProcess(DeleteProcessRequest) returns (google.protobuf.Empty);
|
||||
rpc ListProcesses(ListProcessesRequest) returns (ListProcessesResponse);
|
||||
}
|
||||
|
||||
message StartContainerRequest {
|
||||
string id = 1 [(gogoproto.customname) = "ID"];
|
||||
}
|
||||
|
||||
message StartProcessRequest {
|
||||
string container_id = 1;
|
||||
Process process = 2;
|
||||
string stdin = 3;
|
||||
string stdout = 4;
|
||||
string stderr = 5;
|
||||
}
|
||||
|
||||
message StartProcessResponse {
|
||||
Process process = 1;
|
||||
}
|
||||
|
||||
message Container {
|
||||
string id = 1 [(gogoproto.customname) = "ID"];
|
||||
string bundle_path = 2;
|
||||
Status status = 4;
|
||||
}
|
||||
|
||||
message Process {
|
||||
string id = 1 [(gogoproto.customname) = "ID"];
|
||||
int64 pid = 2;
|
||||
repeated string args = 3;
|
||||
repeated string env = 4;
|
||||
User user = 5;
|
||||
string cwd = 6;
|
||||
bool terminal = 7;
|
||||
uint32 exit_status = 8;
|
||||
}
|
||||
|
||||
enum Status {
|
||||
CREATED = 0;
|
||||
RUNNING = 1;
|
||||
STOPPED = 2;
|
||||
PAUSED = 3;
|
||||
}
|
||||
|
||||
message User {
|
||||
uint32 uid = 1;
|
||||
uint32 gid = 2;
|
||||
repeated uint32 additionalGids = 3;
|
||||
}
|
||||
|
||||
message GetContainerRequest {
|
||||
string id = 1 [(gogoproto.customname) = "ID"];
|
||||
}
|
||||
|
||||
message GetContainerResponse {
|
||||
Container container = 1;
|
||||
}
|
||||
|
||||
message UpdateContainerRequest {
|
||||
Container container = 1;
|
||||
string bundle_path = 2;
|
||||
}
|
||||
|
||||
message PauseContainerRequest {
|
||||
string id = 1 [(gogoproto.customname) = "ID"];
|
||||
}
|
||||
|
||||
message ResumeContainerRequest {
|
||||
string id = 1 [(gogoproto.customname) = "ID"];
|
||||
}
|
||||
|
||||
message GetProcessRequest {
|
||||
Container container = 1;
|
||||
string process_id = 2;
|
||||
}
|
||||
|
||||
message GetProcessResponse {
|
||||
Process process = 1;
|
||||
}
|
||||
|
||||
message SignalProcessRequest {
|
||||
Container container = 1;
|
||||
Process process = 2;
|
||||
uint32 signal = 3;
|
||||
}
|
||||
|
||||
message DeleteProcessRequest {
|
||||
Container container = 1;
|
||||
Process process = 2;
|
||||
}
|
||||
|
||||
message ListProcessesRequest {
|
||||
Container container = 1;
|
||||
}
|
||||
|
||||
message ListProcessesResponse {
|
||||
repeated Process processes = 1;
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -2,16 +2,31 @@ syntax = "proto3";
|
|||
|
||||
package containerd.v1;
|
||||
|
||||
import "container.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
|
||||
service ExecutionService{
|
||||
service ExecutionService {
|
||||
rpc Create(CreateContainerRequest) returns (CreateContainerResponse);
|
||||
rpc Start(StartContainerRequest) returns (google.protobuf.Empty);
|
||||
rpc Update(UpdateContainerRequest) returns (google.protobuf.Empty);
|
||||
rpc Pause(PauseContainerRequest) returns (google.protobuf.Empty);
|
||||
rpc Resume(ResumeContainerRequest) returns (google.protobuf.Empty);
|
||||
rpc Delete(DeleteContainerRequest) returns (google.protobuf.Empty);
|
||||
rpc Get(GetContainerRequest) returns (GetContainerResponse);
|
||||
rpc List(ListContainersRequest) returns (ListContainersResponse);
|
||||
|
||||
rpc StartProcess(StartProcessRequest) returns (StartProcessResponse);
|
||||
rpc GetProcess(GetProcessRequest) returns (GetProcessResponse);
|
||||
rpc SignalProcess(SignalProcessRequest) returns (google.protobuf.Empty);
|
||||
rpc DeleteProcess(DeleteProcessRequest) returns (google.protobuf.Empty);
|
||||
rpc ListProcesses(ListProcessesRequest) returns (ListProcessesResponse);
|
||||
}
|
||||
|
||||
message StartContainerRequest {
|
||||
string id = 1 [(gogoproto.customname) = "ID"];
|
||||
}
|
||||
|
||||
|
||||
message CreateContainerRequest {
|
||||
string id = 1 [(gogoproto.customname) = "ID"];
|
||||
string bundle_path = 2;
|
||||
|
@ -28,9 +43,6 @@ message DeleteContainerRequest {
|
|||
string id = 1 [(gogoproto.customname) = "ID"];
|
||||
}
|
||||
|
||||
message DeleteContainerResponse {
|
||||
}
|
||||
|
||||
message ListContainersRequest {
|
||||
repeated string owner = 1;
|
||||
}
|
||||
|
@ -38,3 +50,94 @@ message ListContainersRequest {
|
|||
message ListContainersResponse {
|
||||
repeated Container containers = 1;
|
||||
}
|
||||
|
||||
message StartProcessRequest {
|
||||
string container_id = 1;
|
||||
Process process = 2;
|
||||
string stdin = 3;
|
||||
string stdout = 4;
|
||||
string stderr = 5;
|
||||
}
|
||||
|
||||
message StartProcessResponse {
|
||||
Process process = 1;
|
||||
}
|
||||
|
||||
message Container {
|
||||
string id = 1 [(gogoproto.customname) = "ID"];
|
||||
string bundle_path = 2;
|
||||
Status status = 4;
|
||||
}
|
||||
|
||||
message Process {
|
||||
string id = 1 [(gogoproto.customname) = "ID"];
|
||||
int64 pid = 2;
|
||||
repeated string args = 3;
|
||||
repeated string env = 4;
|
||||
User user = 5;
|
||||
string cwd = 6;
|
||||
bool terminal = 7;
|
||||
uint32 exit_status = 8;
|
||||
}
|
||||
|
||||
enum Status {
|
||||
CREATED = 0;
|
||||
RUNNING = 1;
|
||||
STOPPED = 2;
|
||||
PAUSED = 3;
|
||||
}
|
||||
|
||||
message User {
|
||||
uint32 uid = 1;
|
||||
uint32 gid = 2;
|
||||
repeated uint32 additionalGids = 3;
|
||||
}
|
||||
|
||||
message GetContainerRequest {
|
||||
string id = 1 [(gogoproto.customname) = "ID"];
|
||||
}
|
||||
|
||||
message GetContainerResponse {
|
||||
Container container = 1;
|
||||
}
|
||||
|
||||
message UpdateContainerRequest {
|
||||
Container container = 1;
|
||||
string bundle_path = 2;
|
||||
}
|
||||
|
||||
message PauseContainerRequest {
|
||||
string id = 1 [(gogoproto.customname) = "ID"];
|
||||
}
|
||||
|
||||
message ResumeContainerRequest {
|
||||
string id = 1 [(gogoproto.customname) = "ID"];
|
||||
}
|
||||
|
||||
message GetProcessRequest {
|
||||
Container container = 1;
|
||||
string process_id = 2;
|
||||
}
|
||||
|
||||
message GetProcessResponse {
|
||||
Process process = 1;
|
||||
}
|
||||
|
||||
message SignalProcessRequest {
|
||||
Container container = 1;
|
||||
Process process = 2;
|
||||
uint32 signal = 3;
|
||||
}
|
||||
|
||||
message DeleteProcessRequest {
|
||||
Container container = 1;
|
||||
Process process = 2;
|
||||
}
|
||||
|
||||
message ListProcessesRequest {
|
||||
Container container = 1;
|
||||
}
|
||||
|
||||
message ListProcessesResponse {
|
||||
repeated Process processes = 1;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
package execution
|
||||
|
||||
//go:generate protoc -I.:../..:../../../../../github.com/gogo/protobuf:/usr/local/include --gogoctrd_out=plugins=grpc,import_path=github.com/docker/containerd/api/execution,Mgogoproto/gogo.proto=github.com/gogo/protobuf/gogoproto,Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor:. execution.proto container.proto
|
||||
//go:generate protoc -I.:../..:../../../../../github.com/gogo/protobuf:/usr/local/include --gogoctrd_out=plugins=grpc,import_path=github.com/docker/containerd/api/execution,Mgogoproto/gogo.proto=github.com/gogo/protobuf/gogoproto,Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/protoc-gen-gogo/descriptor:. execution.proto
|
||||
|
|
|
@ -94,7 +94,6 @@ high performance container runtime
|
|||
|
||||
server := grpc.NewServer()
|
||||
api.RegisterExecutionServiceServer(server, execService)
|
||||
api.RegisterContainerServiceServer(server, execService)
|
||||
go serveGRPC(server, l)
|
||||
|
||||
for s := range signals {
|
||||
|
|
|
@ -61,10 +61,6 @@ var runCommand = cli.Command{
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
containerService, err := getContainerService(context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tmpDir, err := getTempDir(id)
|
||||
if err != nil {
|
||||
|
@ -90,7 +86,7 @@ var runCommand = cli.Command{
|
|||
return err
|
||||
}
|
||||
|
||||
if _, err := containerService.Start(gocontext.Background(), &execution.StartContainerRequest{
|
||||
if _, err := executionService.Start(gocontext.Background(), &execution.StartContainerRequest{
|
||||
ID: cr.Container.ID,
|
||||
}); err != nil {
|
||||
return err
|
||||
|
@ -98,7 +94,7 @@ var runCommand = cli.Command{
|
|||
|
||||
// wait for it to die
|
||||
for {
|
||||
gcr, err := containerService.Get(gocontext.Background(), &execution.GetContainerRequest{
|
||||
gcr, err := executionService.Get(gocontext.Background(), &execution.GetContainerRequest{
|
||||
ID: cr.Container.ID,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -210,14 +206,6 @@ func getExecutionService(context *cli.Context) (execution.ExecutionServiceClient
|
|||
return execution.NewExecutionServiceClient(conn), nil
|
||||
}
|
||||
|
||||
func getContainerService(context *cli.Context) (execution.ContainerServiceClient, error) {
|
||||
conn, err := getGRPCConnection(context)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return execution.NewContainerServiceClient(conn), nil
|
||||
}
|
||||
|
||||
func getTempDir(id string) (string, error) {
|
||||
err := os.MkdirAll(filepath.Join(os.TempDir(), "ctr"), 0700)
|
||||
if err != nil {
|
||||
|
|
|
@ -180,7 +180,6 @@ func (s *Service) ListProcesses(ctx context.Context, r *api.ListProcessesRequest
|
|||
|
||||
var (
|
||||
_ = (api.ExecutionServiceServer)(&Service{})
|
||||
_ = (api.ContainerServiceServer)(&Service{})
|
||||
)
|
||||
|
||||
func toGRPCContainer(container *Container) *api.Container {
|
||||
|
|
Loading…
Reference in a new issue