Skip to content

Commit

Permalink
Merge pull request #3375 from kolyshkin/rm-container-iface
Browse files Browse the repository at this point in the history
libct: rm BaseContainer and Container interfaces
  • Loading branch information
thaJeztah authored Mar 23, 2022
2 parents cae8228 + 102b8ab commit 86d6898
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 194 deletions.
2 changes: 1 addition & 1 deletion delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"golang.org/x/sys/unix"
)

func killContainer(container libcontainer.Container) error {
func killContainer(container *libcontainer.Container) error {
_ = container.Signal(unix.SIGKILL, false)
for i := 0; i < 100; i++ {
time.Sleep(100 * time.Millisecond)
Expand Down
67 changes: 0 additions & 67 deletions libcontainer/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
package libcontainer

import (
"os"
"time"

"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runtime-spec/specs-go"
)

// Status is the status of a container.
Expand Down Expand Up @@ -59,68 +57,3 @@ type BaseState struct {
// Config is the container's configuration.
Config configs.Config `json:"config"`
}

// BaseContainer is a libcontainer container object.
//
// Each container is thread-safe within the same process. Since a container can
// be destroyed by a separate process, any function may return that the container
// was not found. BaseContainer includes methods that are platform agnostic.
type BaseContainer interface {
// Returns the ID of the container
ID() string

// Returns the current status of the container.
Status() (Status, error)

// State returns the current container's state information.
State() (*State, error)

// OCIState returns the current container's state information.
OCIState() (*specs.State, error)

// Returns the current config of the container.
Config() configs.Config

// Returns the PIDs inside this container. The PIDs are in the namespace of the calling process.
//
// Some of the returned PIDs may no longer refer to processes in the Container, unless
// the Container state is PAUSED in which case every PID in the slice is valid.
Processes() ([]int, error)

// Returns statistics for the container.
Stats() (*Stats, error)

// Set resources of container as configured
//
// We can use this to change resources when containers are running.
//
Set(config configs.Config) error

// Start a process inside the container. Returns error if process fails to
// start. You can track process lifecycle with passed Process structure.
Start(process *Process) (err error)

// Run immediately starts the process inside the container. Returns error if process
// fails to start. It does not block waiting for the exec fifo after start returns but
// opens the fifo after start returns.
Run(process *Process) (err error)

// Destroys the container, if its in a valid state, after killing any
// remaining running processes.
//
// Any event registrations are removed before the container is destroyed.
// No error is returned if the container is already destroyed.
//
// Running containers must first be stopped using Signal(..).
// Paused containers must first be resumed using Resume(..).
Destroy() error

// Signal sends the provided signal code to the container's initial process.
//
// If all is specified the signal is sent to all processes in the container
// including the initial process.
Signal(s os.Signal, all bool) error

// Exec signals the container to exec the users process at the end of the init.
Exec() error
}
Loading

0 comments on commit 86d6898

Please sign in to comment.