mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-27 15:57:09 +00:00
Merge pull request #1670 from liubin/1668-remove-ProcessListContainer-API
remove ProcessListContainer API
This commit is contained in:
commit
17d33868c2
@ -65,7 +65,7 @@ $GOPATH/src/github.com/kata-containers/kata-containers/src/agent/protocols/proto
|
|||||||
}
|
}
|
||||||
|
|
||||||
if [ "$(basename $(pwd))" != "agent" ]; then
|
if [ "$(basename $(pwd))" != "agent" ]; then
|
||||||
die "Please go to directory of protocols before execute this shell"
|
die "Please go to root directory of agent before execute this shell"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Protocol buffer files required to generate golang/rust bindings.
|
# Protocol buffer files required to generate golang/rust bindings.
|
||||||
|
@ -32,7 +32,6 @@ service AgentService {
|
|||||||
rpc ExecProcess(ExecProcessRequest) returns (google.protobuf.Empty);
|
rpc ExecProcess(ExecProcessRequest) returns (google.protobuf.Empty);
|
||||||
rpc SignalProcess(SignalProcessRequest) returns (google.protobuf.Empty);
|
rpc SignalProcess(SignalProcessRequest) returns (google.protobuf.Empty);
|
||||||
rpc WaitProcess(WaitProcessRequest) returns (WaitProcessResponse); // wait & reap like waitpid(2)
|
rpc WaitProcess(WaitProcessRequest) returns (WaitProcessResponse); // wait & reap like waitpid(2)
|
||||||
rpc ListProcesses(ListProcessesRequest) returns (ListProcessesResponse);
|
|
||||||
rpc UpdateContainer(UpdateContainerRequest) returns (google.protobuf.Empty);
|
rpc UpdateContainer(UpdateContainerRequest) returns (google.protobuf.Empty);
|
||||||
rpc StatsContainer(StatsContainerRequest) returns (StatsContainerResponse);
|
rpc StatsContainer(StatsContainerRequest) returns (StatsContainerResponse);
|
||||||
rpc PauseContainer(PauseContainerRequest) returns (google.protobuf.Empty);
|
rpc PauseContainer(PauseContainerRequest) returns (google.protobuf.Empty);
|
||||||
@ -126,18 +125,6 @@ message WaitProcessResponse {
|
|||||||
int32 status = 1;
|
int32 status = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListProcessesRequest contains the options used to list running processes inside the container
|
|
||||||
message ListProcessesRequest {
|
|
||||||
string container_id = 1;
|
|
||||||
string format = 2;
|
|
||||||
repeated string args = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ListProcessesResponse represents the list of running processes inside the container
|
|
||||||
message ListProcessesResponse {
|
|
||||||
bytes process_list = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message UpdateContainerRequest {
|
message UpdateContainerRequest {
|
||||||
string container_id = 1;
|
string container_id = 1;
|
||||||
LinuxResources resources = 2;
|
LinuxResources resources = 2;
|
||||||
|
@ -20,9 +20,8 @@ use anyhow::{anyhow, Context, Result};
|
|||||||
use oci::{LinuxNamespace, Root, Spec};
|
use oci::{LinuxNamespace, Root, Spec};
|
||||||
use protobuf::{RepeatedField, SingularPtrField};
|
use protobuf::{RepeatedField, SingularPtrField};
|
||||||
use protocols::agent::{
|
use protocols::agent::{
|
||||||
AgentDetails, CopyFileRequest, GuestDetailsResponse, Interfaces, ListProcessesResponse,
|
AgentDetails, CopyFileRequest, GuestDetailsResponse, Interfaces, Metrics, OOMEvent,
|
||||||
Metrics, OOMEvent, ReadStreamResponse, Routes, StatsContainerResponse, WaitProcessResponse,
|
ReadStreamResponse, Routes, StatsContainerResponse, WaitProcessResponse, WriteStreamResponse,
|
||||||
WriteStreamResponse,
|
|
||||||
};
|
};
|
||||||
use protocols::empty::Empty;
|
use protocols::empty::Empty;
|
||||||
use protocols::health::{
|
use protocols::health::{
|
||||||
@ -576,91 +575,6 @@ impl protocols::agent_ttrpc::AgentService for AgentService {
|
|||||||
.map_err(|e| ttrpc_error(ttrpc::Code::INTERNAL, e.to_string()))
|
.map_err(|e| ttrpc_error(ttrpc::Code::INTERNAL, e.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn list_processes(
|
|
||||||
&self,
|
|
||||||
_ctx: &TtrpcContext,
|
|
||||||
req: protocols::agent::ListProcessesRequest,
|
|
||||||
) -> ttrpc::Result<ListProcessesResponse> {
|
|
||||||
let cid = req.container_id.clone();
|
|
||||||
let format = req.format.clone();
|
|
||||||
let mut args = req.args.into_vec();
|
|
||||||
let mut resp = ListProcessesResponse::new();
|
|
||||||
|
|
||||||
let s = Arc::clone(&self.sandbox);
|
|
||||||
let mut sandbox = s.lock().await;
|
|
||||||
|
|
||||||
let ctr = sandbox.get_container(&cid).ok_or_else(|| {
|
|
||||||
ttrpc_error(
|
|
||||||
ttrpc::Code::INVALID_ARGUMENT,
|
|
||||||
"invalid container id".to_string(),
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let pids = ctr.processes().unwrap();
|
|
||||||
|
|
||||||
match format.as_str() {
|
|
||||||
"table" => {}
|
|
||||||
"json" => {
|
|
||||||
resp.process_list = serde_json::to_vec(&pids).unwrap();
|
|
||||||
return Ok(resp);
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
return Err(ttrpc_error(
|
|
||||||
ttrpc::Code::INVALID_ARGUMENT,
|
|
||||||
"invalid format!".to_string(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// format "table"
|
|
||||||
if args.is_empty() {
|
|
||||||
// default argument
|
|
||||||
args = vec!["-ef".to_string()];
|
|
||||||
}
|
|
||||||
|
|
||||||
let output = tokio::process::Command::new("ps")
|
|
||||||
.args(args.as_slice())
|
|
||||||
.stdout(Stdio::piped())
|
|
||||||
.output()
|
|
||||||
.await
|
|
||||||
.expect("ps failed");
|
|
||||||
|
|
||||||
let out: String = String::from_utf8(output.stdout).unwrap();
|
|
||||||
let mut lines: Vec<String> = out.split('\n').map(|v| v.to_string()).collect();
|
|
||||||
|
|
||||||
let pid_index = lines[0]
|
|
||||||
.split_whitespace()
|
|
||||||
.position(|v| v == "PID")
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let mut result = String::new();
|
|
||||||
result.push_str(lines[0].as_str());
|
|
||||||
|
|
||||||
lines.remove(0);
|
|
||||||
for line in &lines {
|
|
||||||
if line.trim().is_empty() {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let fields: Vec<String> = line.split_whitespace().map(|v| v.to_string()).collect();
|
|
||||||
|
|
||||||
if fields.len() < pid_index + 1 {
|
|
||||||
warn!(sl!(), "corrupted output?");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
let pid = fields[pid_index].trim().parse::<i32>().unwrap();
|
|
||||||
|
|
||||||
for p in &pids {
|
|
||||||
if pid == *p {
|
|
||||||
result.push_str(line.as_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resp.process_list = Vec::from(result);
|
|
||||||
Ok(resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn update_container(
|
async fn update_container(
|
||||||
&self,
|
&self,
|
||||||
_ctx: &TtrpcContext,
|
_ctx: &TtrpcContext,
|
||||||
|
@ -132,9 +132,6 @@ type agent interface {
|
|||||||
// readProcessStderr will tell the agent to read a process stderr
|
// readProcessStderr will tell the agent to read a process stderr
|
||||||
readProcessStderr(ctx context.Context, c *Container, processID string, data []byte) (int, error)
|
readProcessStderr(ctx context.Context, c *Container, processID string, data []byte) (int, error)
|
||||||
|
|
||||||
// processListContainer will list the processes running inside the container
|
|
||||||
processListContainer(ctx context.Context, sandbox *Sandbox, c Container, options ProcessListOptions) (ProcessList, error)
|
|
||||||
|
|
||||||
// updateContainer will update the resources of a running container
|
// updateContainer will update the resources of a running container
|
||||||
updateContainer(ctx context.Context, sandbox *Sandbox, c Container, resources specs.LinuxResources) error
|
updateContainer(ctx context.Context, sandbox *Sandbox, c Container, resources specs.LinuxResources) error
|
||||||
|
|
||||||
|
@ -1125,18 +1125,6 @@ func (c *Container) ioStream(processID string) (io.WriteCloser, io.Reader, io.Re
|
|||||||
return stream.stdin(), stream.stdout(), stream.stderr(), nil
|
return stream.stdin(), stream.stdout(), stream.stderr(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Container) processList(ctx context.Context, options ProcessListOptions) (ProcessList, error) {
|
|
||||||
if err := c.checkSandboxRunning("ps"); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.state.State != types.StateRunning {
|
|
||||||
return nil, fmt.Errorf("Container not running, impossible to list processes")
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.sandbox.agent.processListContainer(ctx, c.sandbox, *c, options)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Container) stats(ctx context.Context) (*ContainerStats, error) {
|
func (c *Container) stats(ctx context.Context) (*ContainerStats, error) {
|
||||||
if err := c.checkSandboxRunning("stats"); err != nil {
|
if err := c.checkSandboxRunning("stats"); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -582,7 +582,6 @@ type VCSandbox interface {
|
|||||||
ResumeContainer(containerID string) error
|
ResumeContainer(containerID string) error
|
||||||
EnterContainer(containerID string, cmd types.Cmd) (VCContainer, *Process, error)
|
EnterContainer(containerID string, cmd types.Cmd) (VCContainer, *Process, error)
|
||||||
UpdateContainer(containerID string, resources specs.LinuxResources) error
|
UpdateContainer(containerID string, resources specs.LinuxResources) error
|
||||||
ProcessListContainer(containerID string, options ProcessListOptions) (ProcessList, error)
|
|
||||||
WaitProcess(containerID, processID string) (int32, error)
|
WaitProcess(containerID, processID string) (int32, error)
|
||||||
SignalProcess(containerID, processID string, signal syscall.Signal, all bool) error
|
SignalProcess(containerID, processID string, signal syscall.Signal, all bool) error
|
||||||
WinsizeProcess(containerID, processID string, height, width uint32) error
|
WinsizeProcess(containerID, processID string, height, width uint32) error
|
||||||
@ -916,7 +915,6 @@ type VCContainer interface {
|
|||||||
* [`EnterContainer`](#entercontainer)
|
* [`EnterContainer`](#entercontainer)
|
||||||
* [`StatusContainer`](#statuscontainer)
|
* [`StatusContainer`](#statuscontainer)
|
||||||
* [`KillContainer`](#killcontainer)
|
* [`KillContainer`](#killcontainer)
|
||||||
* [`ProcessListContainer`](#processlistcontainer)
|
|
||||||
* [`StatsContainer`](#statscontainer)
|
* [`StatsContainer`](#statscontainer)
|
||||||
* [`PauseContainer`](#pausecontainer)
|
* [`PauseContainer`](#pausecontainer)
|
||||||
* [`ResumeContainer`](#resumecontainer)
|
* [`ResumeContainer`](#resumecontainer)
|
||||||
@ -977,13 +975,6 @@ func StatusContainer(sandboxID, containerID string) (ContainerStatus, error)
|
|||||||
func KillContainer(sandboxID, containerID string, signal syscall.Signal, all bool) error
|
func KillContainer(sandboxID, containerID string, signal syscall.Signal, all bool) error
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `ProcessListContainer`
|
|
||||||
```Go
|
|
||||||
// ProcessListContainer is the virtcontainers entry point to list
|
|
||||||
// processes running inside a container
|
|
||||||
func ProcessListContainer(sandboxID, containerID string, options ProcessListOptions) (ProcessList, error)
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `StatsContainer`
|
#### `StatsContainer`
|
||||||
```Go
|
```Go
|
||||||
// StatsContainer return the stats of a running container
|
// StatsContainer return the stats of a running container
|
||||||
|
@ -57,7 +57,6 @@ type VCSandbox interface {
|
|||||||
ResumeContainer(ctx context.Context, containerID string) error
|
ResumeContainer(ctx context.Context, containerID string) error
|
||||||
EnterContainer(ctx context.Context, containerID string, cmd types.Cmd) (VCContainer, *Process, error)
|
EnterContainer(ctx context.Context, containerID string, cmd types.Cmd) (VCContainer, *Process, error)
|
||||||
UpdateContainer(ctx context.Context, containerID string, resources specs.LinuxResources) error
|
UpdateContainer(ctx context.Context, containerID string, resources specs.LinuxResources) error
|
||||||
ProcessListContainer(ctx context.Context, containerID string, options ProcessListOptions) (ProcessList, error)
|
|
||||||
WaitProcess(ctx context.Context, containerID, processID string) (int32, error)
|
WaitProcess(ctx context.Context, containerID, processID string) (int32, error)
|
||||||
SignalProcess(ctx context.Context, containerID, processID string, signal syscall.Signal, all bool) error
|
SignalProcess(ctx context.Context, containerID, processID string, signal syscall.Signal, all bool) error
|
||||||
WinsizeProcess(ctx context.Context, containerID, processID string, height, width uint32) error
|
WinsizeProcess(ctx context.Context, containerID, processID string, height, width uint32) error
|
||||||
|
@ -120,7 +120,6 @@ const (
|
|||||||
grpcListRoutesRequest = "grpc.ListRoutesRequest"
|
grpcListRoutesRequest = "grpc.ListRoutesRequest"
|
||||||
grpcAddARPNeighborsRequest = "grpc.AddARPNeighborsRequest"
|
grpcAddARPNeighborsRequest = "grpc.AddARPNeighborsRequest"
|
||||||
grpcOnlineCPUMemRequest = "grpc.OnlineCPUMemRequest"
|
grpcOnlineCPUMemRequest = "grpc.OnlineCPUMemRequest"
|
||||||
grpcListProcessesRequest = "grpc.ListProcessesRequest"
|
|
||||||
grpcUpdateContainerRequest = "grpc.UpdateContainerRequest"
|
grpcUpdateContainerRequest = "grpc.UpdateContainerRequest"
|
||||||
grpcWaitProcessRequest = "grpc.WaitProcessRequest"
|
grpcWaitProcessRequest = "grpc.WaitProcessRequest"
|
||||||
grpcTtyWinResizeRequest = "grpc.TtyWinResizeRequest"
|
grpcTtyWinResizeRequest = "grpc.TtyWinResizeRequest"
|
||||||
@ -1662,26 +1661,6 @@ func (k *kataAgent) winsizeProcess(ctx context.Context, c *Container, processID
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) processListContainer(ctx context.Context, sandbox *Sandbox, c Container, options ProcessListOptions) (ProcessList, error) {
|
|
||||||
req := &grpc.ListProcessesRequest{
|
|
||||||
ContainerId: c.id,
|
|
||||||
Format: options.Format,
|
|
||||||
Args: options.Args,
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := k.sendReq(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
processList, ok := resp.(*grpc.ListProcessesResponse)
|
|
||||||
if !ok {
|
|
||||||
return nil, fmt.Errorf("Bad list processes response")
|
|
||||||
}
|
|
||||||
|
|
||||||
return processList.ProcessList, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (k *kataAgent) updateContainer(ctx context.Context, sandbox *Sandbox, c Container, resources specs.LinuxResources) error {
|
func (k *kataAgent) updateContainer(ctx context.Context, sandbox *Sandbox, c Container, resources specs.LinuxResources) error {
|
||||||
grpcResources, err := grpc.ResourcesOCItoGRPC(&resources)
|
grpcResources, err := grpc.ResourcesOCItoGRPC(&resources)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1939,9 +1918,6 @@ func (k *kataAgent) installReqFunc(c *kataclient.AgentClient) {
|
|||||||
k.reqHandlers[grpcOnlineCPUMemRequest] = func(ctx context.Context, req interface{}) (interface{}, error) {
|
k.reqHandlers[grpcOnlineCPUMemRequest] = func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
return k.client.AgentServiceClient.OnlineCPUMem(ctx, req.(*grpc.OnlineCPUMemRequest))
|
return k.client.AgentServiceClient.OnlineCPUMem(ctx, req.(*grpc.OnlineCPUMemRequest))
|
||||||
}
|
}
|
||||||
k.reqHandlers[grpcListProcessesRequest] = func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return k.client.AgentServiceClient.ListProcesses(ctx, req.(*grpc.ListProcessesRequest))
|
|
||||||
}
|
|
||||||
k.reqHandlers[grpcUpdateContainerRequest] = func(ctx context.Context, req interface{}) (interface{}, error) {
|
k.reqHandlers[grpcUpdateContainerRequest] = func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
return k.client.AgentServiceClient.UpdateContainer(ctx, req.(*grpc.UpdateContainerRequest))
|
return k.client.AgentServiceClient.UpdateContainer(ctx, req.(*grpc.UpdateContainerRequest))
|
||||||
}
|
}
|
||||||
|
@ -143,9 +143,6 @@ func TestKataAgentSendReq(t *testing.T) {
|
|||||||
err = k.winsizeProcess(ctx, container, execid, 100, 200)
|
err = k.winsizeProcess(ctx, container, execid, 100, 200)
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
|
|
||||||
_, err = k.processListContainer(ctx, sandbox, Container{}, ProcessListOptions{})
|
|
||||||
assert.Nil(err)
|
|
||||||
|
|
||||||
err = k.updateContainer(ctx, sandbox, Container{}, specs.LinuxResources{})
|
err = k.updateContainer(ctx, sandbox, Container{}, specs.LinuxResources{})
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
|
|
||||||
|
@ -86,11 +86,6 @@ func (n *mockAgent) signalProcess(ctx context.Context, c *Container, processID s
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// processListContainer is the Noop agent Container ps implementation. It does nothing.
|
|
||||||
func (n *mockAgent) processListContainer(ctx context.Context, sandbox *Sandbox, c Container, options ProcessListOptions) (ProcessList, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// updateContainer is the Noop agent Container update implementation. It does nothing.
|
// updateContainer is the Noop agent Container update implementation. It does nothing.
|
||||||
func (n *mockAgent) updateContainer(ctx context.Context, sandbox *Sandbox, c Container, resources specs.LinuxResources) error {
|
func (n *mockAgent) updateContainer(ctx context.Context, sandbox *Sandbox, c Container, resources specs.LinuxResources) error {
|
||||||
return nil
|
return nil
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -107,10 +107,6 @@ func (p *HybridVSockTTRPCMockImp) WaitProcess(ctx context.Context, req *pb.WaitP
|
|||||||
return &pb.WaitProcessResponse{}, nil
|
return &pb.WaitProcessResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *HybridVSockTTRPCMockImp) ListProcesses(ctx context.Context, req *pb.ListProcessesRequest) (*pb.ListProcessesResponse, error) {
|
|
||||||
return &pb.ListProcessesResponse{}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *HybridVSockTTRPCMockImp) UpdateContainer(ctx context.Context, req *pb.UpdateContainerRequest) (*gpb.Empty, error) {
|
func (p *HybridVSockTTRPCMockImp) UpdateContainer(ctx context.Context, req *pb.UpdateContainerRequest) (*gpb.Empty, error) {
|
||||||
return emptyResp, nil
|
return emptyResp, nil
|
||||||
}
|
}
|
||||||
|
@ -166,11 +166,6 @@ func (s *Sandbox) UpdateContainer(ctx context.Context, containerID string, resou
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProcessListContainer implements the VCSandbox function of the same name.
|
|
||||||
func (s *Sandbox) ProcessListContainer(ctx context.Context, containerID string, options vc.ProcessListOptions) (vc.ProcessList, error) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// WaitProcess implements the VCSandbox function of the same name.
|
// WaitProcess implements the VCSandbox function of the same name.
|
||||||
func (s *Sandbox) WaitProcess(ctx context.Context, containerID, processID string) (int32, error) {
|
func (s *Sandbox) WaitProcess(ctx context.Context, containerID, processID string) (int32, error) {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
|
@ -53,7 +53,6 @@ type Sandbox struct {
|
|||||||
EnterContainerFunc func(containerID string, cmd types.Cmd) (vc.VCContainer, *vc.Process, error)
|
EnterContainerFunc func(containerID string, cmd types.Cmd) (vc.VCContainer, *vc.Process, error)
|
||||||
MonitorFunc func() (chan error, error)
|
MonitorFunc func() (chan error, error)
|
||||||
UpdateContainerFunc func(containerID string, resources specs.LinuxResources) error
|
UpdateContainerFunc func(containerID string, resources specs.LinuxResources) error
|
||||||
ProcessListContainerFunc func(containerID string, options vc.ProcessListOptions) (vc.ProcessList, error)
|
|
||||||
WaitProcessFunc func(containerID, processID string) (int32, error)
|
WaitProcessFunc func(containerID, processID string) (int32, error)
|
||||||
SignalProcessFunc func(containerID, processID string, signal syscall.Signal, all bool) error
|
SignalProcessFunc func(containerID, processID string, signal syscall.Signal, all bool) error
|
||||||
WinsizeProcessFunc func(containerID, processID string, height, width uint32) error
|
WinsizeProcessFunc func(containerID, processID string, height, width uint32) error
|
||||||
|
@ -1273,19 +1273,6 @@ func (s *Sandbox) DeleteContainer(ctx context.Context, containerID string) (VCCo
|
|||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProcessListContainer lists every process running inside a specific
|
|
||||||
// container in the sandbox.
|
|
||||||
func (s *Sandbox) ProcessListContainer(ctx context.Context, containerID string, options ProcessListOptions) (ProcessList, error) {
|
|
||||||
// Fetch the container.
|
|
||||||
c, err := s.findContainer(containerID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the process list related to the container.
|
|
||||||
return c.processList(ctx, options)
|
|
||||||
}
|
|
||||||
|
|
||||||
// StatusContainer gets the status of a container
|
// StatusContainer gets the status of a container
|
||||||
// TODO: update container status properly, see kata-containers/runtime#253
|
// TODO: update container status properly, see kata-containers/runtime#253
|
||||||
func (s *Sandbox) StatusContainer(containerID string) (ContainerStatus, error) {
|
func (s *Sandbox) StatusContainer(containerID string) (ContainerStatus, error) {
|
||||||
|
@ -79,9 +79,6 @@ const CMD_REPEAT: &'static str = "repeat";
|
|||||||
|
|
||||||
const DEFAULT_PROC_SIGNAL: &'static str = "SIGKILL";
|
const DEFAULT_PROC_SIGNAL: &'static str = "SIGKILL";
|
||||||
|
|
||||||
// Format is either "json" or "table".
|
|
||||||
const DEFAULT_PS_FORMAT: &str = "json";
|
|
||||||
|
|
||||||
const ERR_API_FAILED: &str = "API failed";
|
const ERR_API_FAILED: &str = "API failed";
|
||||||
|
|
||||||
static AGENT_CMDS: &'static [AgentCmd] = &[
|
static AGENT_CMDS: &'static [AgentCmd] = &[
|
||||||
@ -155,11 +152,6 @@ static AGENT_CMDS: &'static [AgentCmd] = &[
|
|||||||
st: ServiceType::Agent,
|
st: ServiceType::Agent,
|
||||||
fp: agent_cmd_sandbox_list_routes,
|
fp: agent_cmd_sandbox_list_routes,
|
||||||
},
|
},
|
||||||
AgentCmd {
|
|
||||||
name: "ListProcesses",
|
|
||||||
st: ServiceType::Agent,
|
|
||||||
fp: agent_cmd_container_list_processes,
|
|
||||||
},
|
|
||||||
AgentCmd {
|
AgentCmd {
|
||||||
name: "MemHotplugByProbe",
|
name: "MemHotplugByProbe",
|
||||||
st: ServiceType::Agent,
|
st: ServiceType::Agent,
|
||||||
@ -1101,40 +1093,6 @@ fn agent_cmd_sandbox_get_guest_details(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn agent_cmd_container_list_processes(
|
|
||||||
ctx: &Context,
|
|
||||||
client: &AgentServiceClient,
|
|
||||||
_health: &HealthClient,
|
|
||||||
options: &mut Options,
|
|
||||||
args: &str,
|
|
||||||
) -> Result<()> {
|
|
||||||
let mut req = ListProcessesRequest::default();
|
|
||||||
|
|
||||||
let ctx = clone_context(ctx);
|
|
||||||
|
|
||||||
let cid = utils::get_option("cid", options, args);
|
|
||||||
|
|
||||||
let mut list_format = utils::get_option("format", options, args);
|
|
||||||
|
|
||||||
if list_format == "" {
|
|
||||||
list_format = DEFAULT_PS_FORMAT.to_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
req.set_container_id(cid);
|
|
||||||
req.set_format(list_format);
|
|
||||||
|
|
||||||
debug!(sl!(), "sending request"; "request" => format!("{:?}", req));
|
|
||||||
|
|
||||||
let reply = client
|
|
||||||
.list_processes(ctx, &req)
|
|
||||||
.map_err(|e| anyhow!("{:?}", e).context(ERR_API_FAILED))?;
|
|
||||||
|
|
||||||
info!(sl!(), "response received";
|
|
||||||
"response" => format!("{:?}", reply));
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn agent_cmd_container_wait_process(
|
fn agent_cmd_container_wait_process(
|
||||||
ctx: &Context,
|
ctx: &Context,
|
||||||
client: &AgentServiceClient,
|
client: &AgentServiceClient,
|
||||||
|
Loading…
Reference in New Issue
Block a user