shim

package
v0.0.0-...-ac6e8c9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2022 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Shim

type Shim struct {
	BaseDir    string
	Container  *container.Container
	Opts       ShimOpts
	SocketPath string
	State      *yacs.YacsState
	// contains filtered or unexported fields
}

Shim represents an instance of the `yacs` shim.

func Load

func Load(rootDir, id string) (*Shim, error)

Load attempts to load a shim configuration from disk. It returns a new shim instance when it succeeds or an error when there is a problem.

func New

func New(container *container.Container, opts ShimOpts) *Shim

New creates a new shim instance for a given container.

func (*Shim) Attach

func (s *Shim) Attach(attachStdin, attachStdout, attachStderr bool) error

Attach attaches the provided Input/Output streams to the container.

func (*Shim) CopyLogs

func (s *Shim) CopyLogs(stdout io.Writer, stderr io.Writer, withTimestamps bool) error

CopyLogs copies all the container logs stored by the shim to the provided writers. Note that this method does NOT use the shim's HTTP API. It reads the container log file directly.

func (*Shim) Create

func (s *Shim) Create(rootDir string) error

Create starts a shim process, which will also create a container by invoking an OCI runtime.

func (*Shim) Delete

func (s *Shim) Delete() error

Delete deletes a container that is not running, otherwise an error will be returned. If the container is not running and not stopped, the shim is terminated first.

All the container files should be deleted as a result of a call to this method and the container will not exist anymore.

func (*Shim) DeleteContainer

func (s *Shim) DeleteContainer() error

DeleteContainer tells the shim to delete the container.

func (*Shim) GetState

func (s *Shim) GetState() (*yacs.YacsState, error)

GetState queries the shim to retrieve its state and returns it.

func (*Shim) OpenStreams

func (s *Shim) OpenStreams() (*os.File, *os.File, *os.File, error)

OpenStreams opens and returns the stdio streams of the container.

func (*Shim) Recreate

func (s *Shim) Recreate(rootDir string) error

Recreate stops a container if it is running and then re-create a new container. If the container is already stopped, we only re-create the container.

func (*Shim) Slirp4netnsApiSocketPath

func (s *Shim) Slirp4netnsApiSocketPath() string

Slirp4netnsApiSocketPath returns the path to the API socket used to communicate with the slirp4netns process.

func (*Shim) Slirp4netnsPidFilePath

func (s *Shim) Slirp4netnsPidFilePath() string

Slirp4netnsPidFilePath returns the path to the file where the slirp4netns process ID should be written when it is started.

func (*Shim) StartContainer

func (s *Shim) StartContainer() error

StartContainer tells the shim to start a container that was previously created.

func (*Shim) StopContainer

func (s *Shim) StopContainer() error

StopContainer tells the shim to stop the container by sending a SIGTERM signal first and a SIGKILL if the first signal didn't stop the container.

func (*Shim) Terminate

func (s *Shim) Terminate() error

Terminate stops the shim if the container is stopped, otherwise an error is returned.

Stopping the shim is performed in two steps: (1) delete the container, and (2) run some clean-up tasks like unmounting the root filesystem, stopping slirp4netns and terminating the shim process.

Once this is done, we persist the final shim state on disk so that other Yaman commands can read and display information until the container is actually deleted. This is one of the main differences with the `Destroy()` method: the shim state is still available.

type ShimOpts

type ShimOpts struct {
	Runtime string
}

ShimOpts contains the options that can be passed to a shim.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL