connect

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRetryPolicy = RetryPolicy{
	MaxAttempts:    3,
	InitialBackoff: 1 * time.Second,
	MaxBackoff:     5 * time.Second,
}

Functions

func IsTransientExecError added in v0.7.3

func IsTransientExecError(err error) bool

IsTransientExecError reports whether err looks like a transport/network-level failure from a kube exec stream (broken pipe, EOF mid-stream, connection reset, etc.) rather than a non-zero command exit. It is the single source of truth for both the retry path in this package and failure classification in callers (e.g. multi-pod exec). Context cancellation and deadline-exceeded errors return false; callers that care about those should check them explicitly with errors.Is.

The patterns are deliberately narrow substrings unique to transport failures. Bare "timeout" is intentionally excluded because remote command stderr (and wrapped error context) commonly contains the word in non-transport senses (e.g. "request timeout from upstream", "nslookup: timed out"); use "i/o timeout", "tls handshake timeout", or "client.timeout exceeded" instead.

func Run

func Run(ctx context.Context, client ExecClient, namespace, pod string, command []string, tty bool, stdin io.Reader, stdout io.Writer, stderr io.Writer) error

func RunOnContainer added in v0.7.0

func RunOnContainer(ctx context.Context, client ExecClient, namespace, pod, container string, command []string, tty bool, stdin io.Reader, stdout io.Writer, stderr io.Writer) error

RunOnContainer executes a command in a specific container within a pod using DefaultRetryPolicy. Transient connect errors are retried the same way as RunWithRetry; non-transient errors (including non-zero command exit codes) surface immediately. If container is empty, it falls back to the pod-level ExecInteractive path.

func RunOnContainerWithRetry added in v0.7.3

func RunOnContainerWithRetry(ctx context.Context, client ExecClient, namespace, pod, container string, command []string, tty bool, stdin io.Reader, stdout io.Writer, stderr io.Writer, policy RetryPolicy) error

RunOnContainerWithRetry is the explicit-policy variant of RunOnContainer.

func RunWithRetry

func RunWithRetry(ctx context.Context, client ExecClient, namespace, pod string, command []string, tty bool, stdin io.Reader, stdout io.Writer, stderr io.Writer, policy RetryPolicy) error

Types

type ExecClient

type ExecClient interface {
	ExecInteractive(ctx context.Context, namespace, pod string, tty bool, command []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error
}

type ExecContainerClient added in v0.7.0

type ExecContainerClient interface {
	ExecClient
	ExecInteractiveInContainer(ctx context.Context, namespace, pod, container string, tty bool, command []string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error
}

ExecContainerClient extends ExecClient with container-targeted exec.

type RetryPolicy

type RetryPolicy struct {
	MaxAttempts    int
	InitialBackoff time.Duration
	MaxBackoff     time.Duration
}

Jump to

Keyboard shortcuts

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