Skip to content

Commit

Permalink
Merge pull request #501 from srl-labs/stop-container
Browse files Browse the repository at this point in the history
remove duration timeout from stopcontainer
  • Loading branch information
hellt committed Jul 8, 2021
2 parents c5fa3ec + 67d4be1 commit 1a86c7d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
6 changes: 2 additions & 4 deletions nodes/ceos/ceos.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"path"
"path/filepath"
"strings"
"time"

log "github.com/sirupsen/logrus"
"github.com/srl-labs/containerlab/nodes"
Expand Down Expand Up @@ -152,9 +151,8 @@ func ceosPostDeploy(ctx context.Context, r runtime.ContainerRuntime, nodeCfg *ty
if err != nil {
return err
}
// force stopping and start is faster than ContainerRestart
var timeout time.Duration = 1
err = r.StopContainer(ctx, nodeCfg.ContainerID, &timeout)

err = r.StopContainer(ctx, nodeCfg.ContainerID)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func (c *ContainerdRuntime) StartContainer(ctx context.Context, containername st
}
return nil
}
func (c *ContainerdRuntime) StopContainer(ctx context.Context, containername string, dur *time.Duration) error {
func (c *ContainerdRuntime) StopContainer(ctx context.Context, containername string) error {
ctask, err := c.getContainerTask(ctx, containername)
if err != nil {
log.Debugf("container %s: %v", containername, err)
Expand Down Expand Up @@ -729,7 +729,7 @@ func (c *ContainerdRuntime) DeleteContainer(ctx context.Context, containerID str
log.Debugf("deleting container %s", containerID)
ctx = namespaces.WithNamespace(ctx, containerdNamespace)

err := c.StopContainer(ctx, containerID, nil)
err := c.StopContainer(ctx, containerID)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ func setSysctl(sysctl string, newVal int) error {
return ioutil.WriteFile(path.Join(sysctlBase, sysctl), []byte(strconv.Itoa(newVal)), 0640)
}

func (c *DockerRuntime) StopContainer(ctx context.Context, name string, dur *time.Duration) error {
func (c *DockerRuntime) StopContainer(ctx context.Context, name string) error {
log.Printf("Stopping container %q", name)
return c.Client.ContainerKill(ctx, name, "kill")
}
2 changes: 1 addition & 1 deletion runtime/ignite/iginite.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (c *IgniteRuntime) StartContainer(ctx context.Context, _ string) error {
// this is a no-op
return nil
}
func (c *IgniteRuntime) StopContainer(ctx context.Context, name string, timeout *time.Duration) error {
func (c *IgniteRuntime) StopContainer(ctx context.Context, name string) error {
// this is a no-op, only used by ceos at this stage
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type ContainerRuntime interface {
// Start pre-created container by its name
StartContainer(context.Context, string) error
// Stop running container by its name
StopContainer(context.Context, string, *time.Duration) error
StopContainer(context.Context, string) error
// List all containers matching labels
ListContainers(context.Context, []*types.GenericFilter) ([]types.GenericContainer, error)
// Get a netns path using the pid of a container
Expand Down

0 comments on commit 1a86c7d

Please sign in to comment.