podlogs

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package podlogs provides generic pod log fetching utilities.

Index

Constants

View Source
const DefaultMaxLogBytes int64 = 8 * 1024 * 1024

DefaultMaxLogBytes caps a single log fetch at 8 MB. Sized well above a normal sampling window (a chatty trainer emits a few hundred KB per minute) while staying far below the controller's memory limit.

View Source
const DefaultStreamTimeout = 2 * time.Minute

DefaultStreamTimeout bounds the complete lifecycle of a pod log request, including opening the stream and consuming its response body.

Variables

This section is empty.

Functions

func OpenStream

func OpenStream(ctx context.Context, req *rest.Request) (io.ReadCloser, error)

OpenStream opens a pod log request bounded by DefaultStreamTimeout or the parent context's deadline, whichever is earlier. The returned stream keeps that deadline active until it is closed, so stalled response-body reads are bounded as well as the initial request.

func ScanLines

func ScanLines(reader io.Reader) ([]string, error)

ScanLines reads all lines from a reader using a buffered scanner with a 1 MB buffer.

Callers are responsible for bounding the reader (see LogOptions.LimitBytes); this returns one string per line and so allocates proportionally to input size.

Types

type LogOptions

type LogOptions struct {
	Container string
	SinceTime *metav1.Time

	// LimitBytes caps how many bytes the API server returns for this fetch.
	// Zero means DefaultMaxLogBytes; reads are never unbounded.
	LimitBytes int64
}

LogOptions configures log reading.

type PodLogFetcher

type PodLogFetcher interface {
	FetchLogs(ctx context.Context, namespace, podName string, opts LogOptions) ([]string, error)
}

PodLogFetcher abstracts fetching raw log lines from a pod.

func NewKubernetesLogFetcher

func NewKubernetesLogFetcher(clientset *kubernetes.Clientset) PodLogFetcher

NewKubernetesLogFetcher creates a PodLogFetcher backed by a Kubernetes clientset.

Jump to

Keyboard shortcuts

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