Skip to content

Commit

Permalink
fix linter complains
Browse files Browse the repository at this point in the history
  • Loading branch information
karimra committed Jun 22, 2021
1 parent 03a13b6 commit f349239
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
20 changes: 13 additions & 7 deletions runtime/containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,6 @@ func (c *ContainerdRuntime) StopContainer(ctx context.Context, containername str
if paused {
if err := ctask.Resume(ctx); err != nil {
log.Warnf("Cannot unpause container %s: %s", containername, err)
} else {
// no need to do it again when send sigkill signal
paused = false
}
}

Expand Down Expand Up @@ -654,13 +651,13 @@ func (c *ContainerdRuntime) exec(ctx context.Context, containername string, cmd
return nil, nil, err
}

NeedToDelete := true
needToDelete := true
p, err := task.LoadProcess(ctx, clabExecId, nil)
if err != nil {
NeedToDelete = false
needToDelete = false
}

if NeedToDelete {
if needToDelete {
log.Debugf("Deleting old process with exec-id %s", clabExecId)
_, err := p.Delete(ctx, containerd.WithProcessKill)
if err != nil {
Expand All @@ -677,7 +674,16 @@ func (c *ContainerdRuntime) exec(ctx context.Context, containername string, cmd
var statusC <-chan containerd.ExitStatus
if !detach {

defer process.Delete(ctx)
defer func() {
exitStatus, err := process.Delete(ctx)
if err != nil {
log.Errorf("failed to delete process: %v", err)
return
}
if exitStatus.Error() != nil {
log.Errorf("failed to delete process: %v", exitStatus.Error())
}
}()

statusC, err = process.Wait(ctx)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions runtime/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,5 @@ func (c *DockerRuntime) ContainerInspect(ctx context.Context, id string) (*types
}

func (c *DockerRuntime) StopContainer(ctx context.Context, name string, dur *time.Duration) error {
c.Client.ContainerKill(ctx, name, "kill")
return nil
return c.Client.ContainerKill(ctx, name, "kill")
}

0 comments on commit f349239

Please sign in to comment.