Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/alibaba/pouch into cri-co…
Browse files Browse the repository at this point in the history
…mpatibility
  • Loading branch information
starnop committed May 18, 2018
2 parents 8d01e30 + 521ca7c commit bd9c4fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 29 deletions.
18 changes: 1 addition & 17 deletions cri/v1alpha2/cri.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,23 +688,7 @@ func (c *CriManager) UpdateContainerResources(ctx context.Context, r *runtime.Up
// to either create a new log file and return nil, or return an error.
// Once it returns error, new container log file MUST NOT be created.
func (c *CriManager) ReopenContainerLog(ctx context.Context, r *runtime.ReopenContainerLogRequest) (*runtime.ReopenContainerLogResponse, error) {
containerID := r.GetContainerId()
container, err := c.ContainerMgr.Get(ctx, containerID)
if err != nil {
return nil, fmt.Errorf("failed to get container of %q: %v", containerID, err)
}
if container.State.Status != apitypes.StatusRunning {
return nil, fmt.Errorf("container %q is not running", containerID)
}
c.ContainerMgr.(*mgr.ContainerManager).IOs.Remove(containerID)
if container.LogPath != "" {
logPath := container.LogPath
err := c.attachLog(logPath, containerID)
if err != nil {
return nil, err
}
}
return &runtime.ReopenContainerLogResponse{}, nil
return nil, fmt.Errorf("UpdateContainerResources Not Implemented Yet")
}

// ExecSync executes a command in the container, and returns the stdout output.
Expand Down
23 changes: 11 additions & 12 deletions daemon/mgr/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type ContainerMgr interface {
// Remove removes a container, it may be running or stopped and so on.
Remove(ctx context.Context, name string, option *types.ContainerRemoveOptions) error

// 2. The following five functions is related to containr exec.
// 2. The following five functions is related to container exec.

// CreateExec creates exec process's environment.
CreateExec(ctx context.Context, name string, config *types.ExecCreateConfig) (string, error)
Expand Down Expand Up @@ -1674,16 +1674,6 @@ func (mgr *ContainerManager) exitedAndRelease(id string, m *ctrd.Message) error
// execExitedAndRelease be register into ctrd as a callback function, when the exec process in a container
// exited, "ctrd" will call it to release resource and so on.
func (mgr *ContainerManager) execExitedAndRelease(id string, m *ctrd.Message) error {
if io := mgr.IOs.Get(id); io != nil {
if err := m.RawError(); err != nil {
fmt.Fprintf(io.Stdout, "%v\n", err)
}

// close io
io.Close()
mgr.IOs.Remove(id)
}

v, ok := mgr.ExecProcesses.Get(id).Result()
if !ok {
return errors.Wrap(errtypes.ErrNotfound, "to be exec process: "+id)
Expand All @@ -1696,7 +1686,16 @@ func (mgr *ContainerManager) execExitedAndRelease(id string, m *ctrd.Message) er
execConfig.Running = false
execConfig.Error = m.RawError()

// TODO: GC invalid mgr.ExecProcess.
if io := mgr.IOs.Get(id); io != nil {
if err := m.RawError(); err != nil {
fmt.Fprintf(io.Stdout, "%v\n", err)
}

// close io
io.Close()
mgr.IOs.Remove(id)
}

return nil
}

Expand Down

0 comments on commit bd9c4fd

Please sign in to comment.