explorers

package
v0.0.2-20220209 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTaskPID

func GetTaskPID(path string) int

GetTaskPID returns process ID of the containers

func GetTaskStatus

func GetTaskStatus(cgrouppath string) (string, error)

GetTaskStatus returns task status

func PathExists

func PathExists(path string, isfile bool) bool

PathExists returns true if the path exists

func ReadCgroupEvents

func ReadCgroupEvents(path string) (int, int, error)

ReadCgroupEvents returns populated and frozen status

Types

type Container

type Container struct {
	Namespace        string
	Hostname         string
	ImageBase        string
	SupportContainer bool
	ContainerType    string
	ProcessID        int
	Status           string

	// containerd specific fields
	containers.Container

	// docker specific fields
	Running      bool
	ExposedPorts []string
}

Container provides information about a container.

type ContainerExplorer

type ContainerExplorer interface {

	// SnapshotRoot returns the directory containing snapshots and snapshot
	// database i.e. metadata.db
	//
	// SnapshotRoot is required for the containers managed using containerd.
	SnapshotRoot(snapshotter string) string

	// ListNamespaces returns all the namespaces in the metadata file i.e.
	// meta.db
	ListNamespaces(ctx context.Context) ([]string, error)

	// ListContainers returns all the containers in all the namespaces.
	//
	// ListContainers returns the ContainerExplorer's Containers structure
	// that holds additional information about the containers.
	ListContainers(ctx context.Context) ([]Container, error)

	// ListImages returns content information
	ListImages(ctx context.Context) ([]Image, error)

	// ListSnapshots returns the snapshot information
	ListSnapshots(ctx context.Context) ([]SnapshotKeyInfo, error)

	// ListContent returns information about content
	ListContent(ctx context.Context) ([]Content, error)

	// ListTasks returns the container task status
	ListTasks(ctx context.Context) ([]Task, error)

	// InfoContainer returns container internal information
	InfoContainer(ctx context.Context, containerid string, spec bool) (interface{}, error)

	// MountContainer mounts a container to the specified path
	MountContainer(ctx context.Context, containerid string, mountpoint string) error

	// MountAllContainer mounts all containers to the specfied path
	MountAllContainers(ctx context.Context, mountpoint string, skipsupportcontainers bool) error

	// Close releases the internal resources
	Close() error
}

ContainerExplorer defines the methods required to explore a container.

type Content

type Content struct {
	Namespace string
	content.Info
}

Content provides information about containers' content

type Image

type Image struct {
	Namespace             string
	SupportContainerImage bool
	images.Image
}

Image provides information about a container image.

type SnapshotKeyInfo

type SnapshotKeyInfo struct {
	Namespace   string            // namespace only used in meta.db
	Snapshotter string            // only used in meta.db
	Key         string            // snapshot key
	ID          uint64            // File system ID. Only used in metadata.db
	Name        string            // snapshot name. Only used in meta.db
	Parent      string            // snapshot parent
	Kind        snapshots.Kind    // snapshot kind
	Inodes      []int64           // Inode numbers. Only in metadata.db
	Size        uint64            // Only in metadata.db
	OverlayPath string            // Custom field added by container explorer
	Labels      map[string]string // mapped labels
	Children    []string          // array of <snapshot key>. Only in meta.db
	CreatedAt   time.Time         // created timestamp
	UpdatedAt   time.Time         // updated timestamp
}

SnapshotKeyInfo provides information about snapshots.

SnapshotKeyInfo contains information found in containerd metadata (meta.db) and snapshot database (metadata.db).

type State

type State struct {
	ID                  string                 `json:"state,omitempty"`
	InitProcessPid      int                    `json:"init_process_pid"`
	InitProcessstart    int                    `json:"init_process_start"`
	Created             time.Time              `json:"created"`
	Config              map[string]interface{} `json:"config"`
	Rootless            bool                   `json:"rootless"`
	CgroupPaths         map[string]string      `json:"cgroup_paths"`
	NamespacePaths      map[string]string      `json:"namespace_paths"`
	ExternalDescriptors []string               `json:"external_descriptors"`
	IntelRdtPath        string                 `json:"intel_rdt_path"`
}

State holds runc state information.

runc state file is located at `/run/containerd/runc/<namespace>/<container_id>/state.json`.

The State structure only maps the required attributes form state.json.

type SupportContainer

type SupportContainer struct {
	ContainerNames []string `json:"names" yaml:"names"`
	ImageNames     []string `json:"images" yaml:"images"`
	Labels         []string `json:"labels" yaml:"labels"`
}

SupportContainer contains information about support container.

A support container can be identified by: - Container or pod hostname - Image name - Container labels or annotations

func LoadSupportContainerFromFile

func LoadSupportContainerFromFile(path string) (SupportContainer, error)

LoadSupportContainerFromFile loads the support container information from a yaml file on disk.

func NewSupportContainer

func NewSupportContainer(path string) (*SupportContainer, error)

NewSupportContainer returns the support container instance.

func (*SupportContainer) IsSupportContainer

func (sc *SupportContainer) IsSupportContainer(ctr Container) bool

IsSupportContainer returns if the support container

func (*SupportContainer) JSON

func (sc *SupportContainer) JSON() string

JSON returns the data in json

func (*SupportContainer) SupportContainerImage

func (sc *SupportContainer) SupportContainerImage(image string) bool

SupportContainerImage returns true if the supplied image is a known support container image.

func (*SupportContainer) SupportContainerLabel

func (sc *SupportContainer) SupportContainerLabel(label string) bool

SupportContainerLabel returns true if the supplied name is a known support container label

func (*SupportContainer) SupportContainerName

func (sc *SupportContainer) SupportContainerName(name string) bool

SupportContainerName returns true if the supplied name is a known support container name.

type Task

type Task struct {
	Namespace     string
	Name          string
	PID           int
	ContainerType string
	Status        string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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