fileprovider

package
v0.0.0-...-407d013 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// WildcardUseFileModTime means that the top 'filesLimit' most recently modified files
	// will be chosen from all wildcard matches
	WildcardUseFileModTime = iota
	// WildcardUseFileName means that wildcard matches will be chosen in a roughly reverse
	// lexicographical order
	WildcardUseFileName
)

Variables

View Source
var ContainersLogsDir = "/var/log/containers"

ContainersLogsDir is the directory in which we should find containers logsfile with the container ID in their filename. Public to be able to change it while running unit tests.

Functions

func ShouldIgnore

func ShouldIgnore(validatePodContainerID bool, file *tailer.File) bool

ShouldIgnore resolves symlinks in /var/log/containers in order to use that redirection to validate that we will be reading a file for the correct container.

We have to make sure that the file we just detected is tagged with the correct container ID if the source is a container source and `logs_config.validate_pod_container_id` is enabled`. The way k8s is storing files in /var/log/pods doesn't let us do that properly (the filename doesn't contain the container ID). However, the symlinks present in /var/log/containers are pointing to /var/log/pods files does, meaning that we can use them to validate that the file we have found is concerning us. That's what the function shouldIgnore is trying to do when the directory exists and is readable. See these links for more info:

Types

type FileProvider

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

FileProvider implements the logic to retrieve at most filesLimit Files defined in sources

func NewFileProvider

func NewFileProvider(filesLimit int, wildcardSelection WildcardSelectionStrategy) *FileProvider

NewFileProvider returns a new Provider

func (*FileProvider) CollectFiles

func (p *FileProvider) CollectFiles(source *sources.LogSource) ([]*tailer.File, error)

CollectFiles takes a 'LogSource' and produces a list of tailers matching this source with ordering defined by 'wildcardOrder'

func (*FileProvider) FilesToTail

func (p *FileProvider) FilesToTail(validatePodContainerID bool, inputSources []*sources.LogSource) []*tailer.File

FilesToTail returns all the Files matching paths in sources, it cannot return more than filesLimit Files. Files are collected according to the fileProvider's wildcardOrder and selectionMode

type WildcardSelectionStrategy

type WildcardSelectionStrategy int

WildcardSelectionStrategy is used to specify if wildcard matches should be prioritized based on their filename or the modification time of each file

Jump to

Keyboard shortcuts

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