kubernetes: k8s.io/kubernetes/test/e2e/framework/podlogs Index | Files

package podlogs

import "k8s.io/kubernetes/test/e2e/framework/podlogs"

Package podlogs enables live capturing of all events and log messages for some or all pods in a namespace as they get generated. This helps debugging both a running test (what is currently going on?) and the output of a CI run (events appear in chronological order and output that normally isn't available like the command stdout messages are available).

Index

Package Files

podlogs.go

func CopyAllLogs Uses

func CopyAllLogs(ctx context.Context, cs clientset.Interface, ns string, to LogOutput) error

CopyAllLogs follows the logs of all containers in all pods, including those that get created in the future, and writes each log line as configured in the output options. It does that until the context is done or until an error occurs.

Beware that there is currently no way to force log collection before removing pods, which means that there is a known race between "stop pod" and "collecting log entries". The alternative would be a blocking function with collects logs from all currently running pods, but that then would have the disadvantage that already deleted pods aren't covered.

func LogsForPod Uses

func LogsForPod(ctx context.Context, cs clientset.Interface, ns, pod string, opts *v1.PodLogOptions) (io.ReadCloser, error)

LogsForPod starts reading the logs for a certain pod. If the pod has more than one container, opts.Container must be set. Reading stops when the context is done. The stream includes formatted error messages and ends with

rpc error: code = Unknown desc = Error: No such container: 41a...

when the pod gets deleted while streaming.

func WatchPods Uses

func WatchPods(ctx context.Context, cs clientset.Interface, ns string, to io.Writer) error

WatchPods prints pod status events for a certain namespace or all namespaces when namespace name is empty.

type LogOutput Uses

type LogOutput struct {
    // If not nil, errors will be logged here.
    StatusWriter io.Writer

    // If not nil, all output goes to this writer with "<pod>/<container>:" as prefix.
    LogWriter io.Writer

    // Base directory for one log file per container.
    // The full path of each log file will be <log path prefix><pod>-<container>.log.
    LogPathPrefix string
}

LogOutput determines where output from CopyAllLogs goes.

Package podlogs imports 14 packages (graph) and is imported by 21 packages. Updated 2019-09-16. Refresh now. Tools for package owners.