Documentation

Overview

Package processmon is to manage and monitor remote enforcers. When we access the processmanager interface through here it acts as a singleton The ProcessMonitor interface is not a singleton and can be used to monitor a list of processes

Index

Constants

This section is empty.

Variables

View Source
var ErrBinaryNotFound = errors.New("Enforcer Binary not found")

ErrBinaryNotFound Exported

View Source
var ErrEnforcerAlreadyRunning = errors.New("Enforcer already running in this context")

ErrEnforcerAlreadyRunning Exported

View Source
var ErrFailedtoLaunch = errors.New("Failed to launch enforcer")

ErrFailedtoLaunch Exported

View Source
var ErrProcessDoesNotExists = errors.New("Process in that context does not exist")

ErrProcessDoesNotExists Exported

View Source
var ErrSymLinkFailed = errors.New("Failed to create symlink for use by ip netns")

ErrSymLinkFailed Exported

View Source
var (
	// GlobalCommandArgs are command args received while invoking this command
	GlobalCommandArgs map[string]interface{}
)

Functions

This section is empty.

Types

type ExitStatus

type ExitStatus struct {

	// contains filtered or unexported fields

}

ExitStatus captures the exit status of a process The contextID is optional and is primarily used by remote enforcer processes and represents the namespace in which the process was running

type ProcessManager

type ProcessManager interface {
	GetExitStatus(contextID string) bool
	SetExitStatus(contextID string, status bool) error
	KillProcess(contextID string)
	LaunchProcess(contextID string, refPid int, refNsPath string, rpchdl rpcwrapper.RPCClient, arg string, statssecret string, procMountPoint string) error
	SetnsNetPath(netpath string)
}

ProcessManager interface exposes methods required by a processmonitor

func GetProcessManagerHdl

func GetProcessManagerHdl() ProcessManager

GetProcessManagerHdl will ensure that we return an existing handle if one has been created. or return a new one if there is none This needs locks

func NewTestProcessMon

func NewTestProcessMon() ProcessManager

NewTestProcessMon creates a mock process manager

type ProcessMon

type ProcessMon struct {
	// contains filtered or unexported fields

}

ProcessMon exported

func (*ProcessMon) GetExitStatus

func (p *ProcessMon) GetExitStatus(contextID string) bool

GetExitStatus reports if the process is marked for deletion or deleted

func (*ProcessMon) KillProcess

func (p *ProcessMon) KillProcess(contextID string)

KillProcess sends a rpc to the process to exit failing which it will kill the process

func (*ProcessMon) LaunchProcess

func (p *ProcessMon) LaunchProcess(contextID string, refPid int, refNSPath string, rpchdl rpcwrapper.RPCClient, arg string, statsServerSecret string, procMountPoint string) error

LaunchProcess prepares the environment for the new process and launches the process

func (*ProcessMon) SetExitStatus

func (p *ProcessMon) SetExitStatus(contextID string, status bool) error

SetExitStatus marks the process for deletion

func (*ProcessMon) SetnsNetPath

func (p *ProcessMon) SetnsNetPath(netpath string)

SetnsNetPath -- only planned consumer is unit test Call this function if you expect network namespace links to be created in a separate path

type TestProcessManager

type TestProcessManager interface {
	ProcessManager
	MockGetExitStatus(t *testing.T, impl func(string) bool)
	MockKillProcess(t *testing.T, impl func(string))
	MockLaunchProcess(t *testing.T, impl func(string, int, string, rpcwrapper.RPCClient, string, string, string) error)
	MockSetExitStatus(t *testing.T, impl func(string, bool) error)
	MockSetnsNetPath(t *testing.T, impl func(string))
}

TestProcessManager is a mock process manager