debugagent

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2021 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MemFile       string = "/proc/meminfo"
	CpuFile       string = "/proc/cpuinfo"
	UpTimeFile    string = "/proc/uptime"
	SwapsFile     string = "/proc/swaps"
	StatFile      string = "/proc/stat"
	DiskStatsFile string = "/proc/diskstats"
	LoadavgFile   string = "/proc/loadavg"
)

List of LXC filesystem files

View Source
const (
	DockerScheme     ContainerRuntimeScheme = "docker"
	ContainerdScheme ContainerRuntimeScheme = "containerd"
	KubectlDebugNS   string                 = "kctldbg"
	K8NS             string                 = "k8s.io"
)

Variables

View Source
var (
	// IsLxcfsEnabled means whether to enable lxcfs
	LxcfsEnabled bool

	// LxcfsRootDir
	LxcfsRootDir = "/var/lib/lxc"

	// LxcfsHomeDir means /var/lib/lxc/lxcfs
	LxcfsHomeDir = "/var/lib/lxc/lxcfs"

	// LxcfsFiles is a list of LXC files
	LxcfsProcFiles = []string{MemFile, CpuFile, UpTimeFile, SwapsFile, StatFile, DiskStatsFile, LoadavgFile}
)
View Source
var DebugAttacherImplementsAttacher kubeletremote.Attacher = (*DebugAttacher)(nil)
View Source
var (
	DefaultConfig = Config{
		DockerEndpoint:        "unix:///var/run/docker.sock",
		ContainerdEndpoint:    "/run/containerd/containerd.sock",
		RuntimeTimeout:        30 * time.Second,
		StreamIdleTimeout:     10 * time.Minute,
		StreamCreationTimeout: 15 * time.Second,
		ListenAddress:         "0.0.0.0:10027",
		AuditFifo:             "/var/data/kubectl-debug-audit-fifo/KCTLDBG-CONTAINER-ID",
		AuditShim:             []string{"/usr/bin/strace", "-o", "KCTLDBG-FIFO", "-f", "-e", "trace=/exec"},
	}
)
View Source
var PushTracker = docker.NewInMemoryTracker()

Functions

func CheckLxcfsMount

func CheckLxcfsMount() error

CheckLxcfsMount check if the the mount point of lxcfs exists

func Display

func Display(w io.Writer, statuses []StatusInfo, start time.Time)

func GetIPCNamespace

func GetIPCNamespace(pid int64) string

func GetNetworkNamespace

func GetNetworkNamespace(pid int64) string

func GetPIDNamespace

func GetPIDNamespace(pid int64) string

func GetUserNamespace

func GetUserNamespace(pid int64) string

func HandleResizing

func HandleResizing(resize <-chan remotecommand.TerminalSize, resizeFunc func(size remotecommand.TerminalSize))

handleResizing spawns a goroutine that processes the resize channel, calling resizeFunc for each remotecommand.TerminalSize received from the channel. The resize channel must be closed elsewhere to stop the goroutine.

Types

type Config

type Config struct {
	DockerEndpoint        string        `yaml:"docker_endpoint,omitempty"`
	ContainerdEndpoint    string        `yaml:"containerd_endpoint,omitempty"`
	RuntimeTimeout        time.Duration `yaml:"runtime_timeout,omitempty"`
	StreamIdleTimeout     time.Duration `yaml:"stream_idle_timeout,omitempty"`
	StreamCreationTimeout time.Duration `yaml:"stream_creation_timeout,omitempty"`
	ListenAddress         string        `yaml:"listen_address,omitempty"`
	Verbosity             int           `yaml:"verbosity,omitempty"`
	Audit                 bool          `yaml:"audit,omitempty"`
	AuditFifo             string        `yaml:"audit_fifo,omitempty"`
	AuditShim             []string      `yaml:"audit_shim,omitempty"`
}

func Load

func Load(s string) (*Config, error)

func LoadFile

func LoadFile(filename string) (*Config, error)

type ContainerInfo

type ContainerInfo struct {
	Pid               int64
	MountDestinations []string
}

type ContainerRuntime

type ContainerRuntime interface {
	PullImage(ctx context.Context, image string,
		skipTLS bool, authStr string,
		cfg RunConfig) error
	ContainerInfo(ctx context.Context, cfg RunConfig) (ContainerInfo, error)
	RunDebugContainer(cfg RunConfig) error
}
var ContainerdContainerRuntimeImplementsContainerRuntime ContainerRuntime = (*ContainerdContainerRuntime)(nil)
var DockerContainerRuntimeImplementsContainerRuntime ContainerRuntime = (*DockerContainerRuntime)(nil)

type ContainerRuntimeScheme

type ContainerRuntimeScheme string

type ContainerdContainerRuntime

type ContainerdContainerRuntime struct {
	// contains filtered or unexported fields
}

func (*ContainerdContainerRuntime) ContainerInfo

func (c *ContainerdContainerRuntime) ContainerInfo(
	ctx context.Context, cfg RunConfig) (ContainerInfo, error)

func (*ContainerdContainerRuntime) PullImage

func (c *ContainerdContainerRuntime) PullImage(
	ctx context.Context, image string, skipTLS bool,
	authStr string,
	cfg RunConfig) error

func (*ContainerdContainerRuntime) RunDebugContainer

func (c *ContainerdContainerRuntime) RunDebugContainer(cfg RunConfig) error

type DebugAttacher

type DebugAttacher struct {
	// contains filtered or unexported fields
}

DebugAttacher implements Attacher we use this struct in order to inject debug info (image, command) in the debug procedure

func (*DebugAttacher) AttachContainer

func (a *DebugAttacher) AttachContainer(name string, uid kubetype.UID, container string, in io.Reader, out, err io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize) error

Implement kubeletremote.Attacher

func (*DebugAttacher) DebugContainer

func (m *DebugAttacher) DebugContainer(cfg RunConfig) error

DebugContainer executes the main debug flow

func (*DebugAttacher) SetContainerLxcfs

func (m *DebugAttacher) SetContainerLxcfs(cfg RunConfig) error

type DockerContainerRuntime

type DockerContainerRuntime struct {
	// contains filtered or unexported fields
}

func (*DockerContainerRuntime) AttachToContainer

func (c *DockerContainerRuntime) AttachToContainer(cfg RunConfig, container string) error

AttachToContainer do `docker attach`. Blocks until container I/O complete

func (*DockerContainerRuntime) CleanContainer

func (c *DockerContainerRuntime) CleanContainer(cfg RunConfig, id string)

func (*DockerContainerRuntime) ContainerInfo

func (c *DockerContainerRuntime) ContainerInfo(ctx context.Context, cfg RunConfig) (ContainerInfo, error)

func (*DockerContainerRuntime) CreateContainer

func (*DockerContainerRuntime) PullImage

func (c *DockerContainerRuntime) PullImage(ctx context.Context,
	image string, skipTLS bool, authStr string,
	cfg RunConfig) error

func (*DockerContainerRuntime) RmContainer

func (c *DockerContainerRuntime) RmContainer(cfg RunConfig, id string, force bool) error

func (*DockerContainerRuntime) RunDebugContainer

func (c *DockerContainerRuntime) RunDebugContainer(cfg RunConfig) error

func (*DockerContainerRuntime) StartContainer

func (c *DockerContainerRuntime) StartContainer(cfg RunConfig, id string) error

Run a new container, this container will join the network, mount, and pid namespace of the given container

type RunConfig

type RunConfig struct {
	// contains filtered or unexported fields
}

type RuntimeManager

type RuntimeManager struct {
	// contains filtered or unexported fields
}

RuntimeManager is responsible for docker operation

func NewRuntimeManager

func NewRuntimeManager(srvCfg Config, containerUri string, verbosity int,
	hstNm, usrNm string) (*RuntimeManager, error)

func (*RuntimeManager) GetAttacher

func (m *RuntimeManager) GetAttacher(image, authStr string,
	lxcfsEnabled, registrySkipTLS bool,
	command []string, context context.Context,
	cancel context.CancelFunc) kubeletremote.Attacher

GetAttacher returns an implementation of Attacher

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(config *Config) (*Server, error)

func (*Server) Healthz

func (s *Server) Healthz(w http.ResponseWriter, req *http.Request)

func (*Server) Run

func (s *Server) Run() error

func (*Server) ServeDebug

func (s *Server) ServeDebug(w http.ResponseWriter, req *http.Request)

ServeDebug serves the debug request. first, it will upgrade the connection to SPDY. then, server will try to create the debug container, and sent creating progress to user via SPDY. after the debug container running, server attach to the debug container and pipe the streams to user. once connection closed, server killed the debug container and release related resources if any error occurs above, an error status were written to the user's stderr.

type StatusInfo

type StatusInfo struct {
	Ref       string
	Status    string
	Offset    int64
	Total     int64
	StartedAt time.Time
	UpdatedAt time.Time
}

Jump to

Keyboard shortcuts

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