containerwatcher

package
v1.13.3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTimeout = fmt.Errorf("timeout while waiting")

Functions

func FileExists

func FileExists(filePath string) (bool, error)

func FilterProcessList

func FilterProcessList(procs []ps.Process, filterPids sets.Int, allowedParentPid int) ([]ps.Process, error)

given list of processes returns a list of processes such that, the pid does not match any of the given filterPids, this is to filter the /pause and current process. and the parentPid is the allowedParentPid. The logic for this is because every process in the shared namespace always has a parent pid of 0

Types

type ContainerInformation

type ContainerInformation struct {
	Namespace string
	PodName   string
	Name      string
}

type NoopWatcher

type NoopWatcher struct {
}

func (NoopWatcher) WaitToExit

func (n NoopWatcher) WaitToExit(ctx context.Context) error

func (NoopWatcher) WaitToStart

func (n NoopWatcher) WaitToStart(ctx context.Context) error

type SharedNamespaceProcessLister

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

func (*SharedNamespaceProcessLister) AnyProcessRunning

func (s *SharedNamespaceProcessLister) AnyProcessRunning(ctx context.Context) (bool, error)

func (*SharedNamespaceProcessLister) ListRunningProcesses

func (s *SharedNamespaceProcessLister) ListRunningProcesses(ctx context.Context) ([]ps.Process, error)

Polls all processes and returns a filtered set. Refer to FilterProcessList for understanding the process of filtering

type Watcher

type Watcher interface {
	WaitToStart(ctx context.Context) error
	WaitToExit(ctx context.Context) error
}

func NewKubeAPIWatcher

func NewKubeAPIWatcher(_ context.Context, clientConfig clientcmd.ClientConfig, info ContainerInformation) (Watcher, error)

func NewSharedProcessNSWatcher

func NewSharedProcessNSWatcher(ctx context.Context, pollInterval time.Duration, waitNumIntervalsBeforeFinalize int) (Watcher, error)

c -> clock.Clock allows for injecting a fake clock. The watcher uses a timer pollInterval -> time.Duration, wait for this amount of time between successive process checks waitNumIntervalsBeforeFinalize -> Number of successive poll intervals of missing processes for the container, before assuming process is complete. 0/1 indicate the first time a process is detected to be missing, the wait if finalized. containerStartupTimeout -> Duration for which to wait for the container to start up. If the container has not started up in this time, exit with error.

func NewSuccessFileWatcher

func NewSuccessFileWatcher(_ context.Context, watchDir, startFileName, successFileName, errorFileName string) (Watcher, error)

type WatcherType

type WatcherType = string
const (
	// Uses KubeAPI to determine if the container is completed
	WatcherTypeKubeAPI WatcherType = "kube-api"
	// Uses a success file to determine if the container has completed.
	// CAUTION: Does not work if the container exits because of OOM, etc
	WatcherTypeFile WatcherType = "file"
	// Uses Kube 1.17 feature - https://kubernetes.io/docs/tasks/configure-pod-container/share-process-namespace/
	// To look for pid in the shared namespace.
	WatcherTypeSharedProcessNS WatcherType = "shared-process-ns"
	// Dummy watcher. Exits immediately, assuming success
	WatcherTypeNoop WatcherType = "noop"
)

Jump to

Keyboard shortcuts

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