containersorpods

package
v0.0.0-...-6caf7d7 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chooser

type Chooser interface {
	// Wait blocks until a decision is made, or the given context is cancelled.
	Wait(ctx context.Context) LogWhat

	// Get is identical to Wait, except that it returns LogUnknown immediately
	// in any situation where Wait would wait.
	Get() LogWhat
}

Chooser determines how the logs-agent should handle containers: either monitoring individual containers, or monitoring pods and logging the containers within them.

The decision is rather complex:

  • if any of the container features (docker, containerd, cri, podman) are present and kubernetes is not, wait for the dockerutil service to start and return LogContainers
  • if the kubernetes feature is available and no container features are available, wait for the kubelet service to start, and return LogPods
  • if none of the features are available, LogNothing
  • if at least one container feature _and_ the kubernetes feature are available, then wait for either of the dockerutil service or the kubelet service to start. This always tries both at the same time, and if both are available will return LogPods if `logs_config.k8s_container_use_file` is true or LogContainers if the configuration setting is false.

If this function returns LogPods, then the caller may assume the kubelet service is available. Similarly, if this function returns LogContainers, then the caller may assume the dockerutil service is available.

The dependency on the configuration value is based on the observation that the kubernetes launcher always uses files to log pods, while the docker launcher (in some circumstances, at least) does not.

func NewChooser

func NewChooser() Chooser

NewChooser returns a new Chooser.

func NewDecidedChooser

func NewDecidedChooser(decision LogWhat) Chooser

NewDecidedChooser returns a new Chooser where the choice is predetermined. This is for use in unit tests.

type LogWhat

type LogWhat int

LogWhat is the answer this package provides

const (
	// LogContainers means that the logs-agent should log containers, not pods.
	LogContainers LogWhat = iota

	// LogPods means that the logs-agent should log pods, not containers.
	LogPods

	// LogUnknown indicates that it's too early to tell which should be used, because
	// neither service has become available yet.
	LogUnknown

	// LogNothing means neither containers nor pods are supported.
	LogNothing
)

func (LogWhat) String

func (lw LogWhat) String() string

Jump to

Keyboard shortcuts

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