Documentation
¶
Overview ¶
Package common holds low-level primitives shared across the aks-node-controller commands.
The HTTP helpers here are the reusable transport/retry mechanics for the check-hotfix network calls (the IMDS attested-token GET and the live-patching-service hotfix-pointer GET) and are intentionally domain-agnostic: callers supply their own timeouts, TLS trust, dial override, overall deadline, and retry policy. Endpoint identity and timeout tuning live with the caller, not here.
TODO(provisioning-hotfix): when the check-lps connectivity client (lps.go) lands in main, have it consume NewBaseTransport too so there is a single canonical HTTP client.
Index ¶
- func NewBaseTransport(opts HTTPTransportOptions) *http.Transport
- func RetryFetch[T any](ctx context.Context, maxAttempts int, retryable func(error) bool, ...) (T, error)
- func RetryStringFetch(ctx context.Context, maxAttempts int, fn func(context.Context) (string, error)) (string, error)
- type HTTPTransportOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBaseTransport ¶
func NewBaseTransport(opts HTTPTransportOptions) *http.Transport
NewBaseTransport builds an *http.Transport with fail-fast connect/handshake/response timeouts and proxying disabled. Proxying is disabled unconditionally: the LPS client forces its dial to the apiserver front (a proxy CONNECT would defeat the --resolve pin) and IMDS is a link-local endpoint that must never be proxied. Retry and overall-deadline policy are layered by callers.
func RetryFetch ¶ added in v0.20261009.0
func RetryFetch[T any]( ctx context.Context, maxAttempts int, retryable func(error) bool, fn func(context.Context) (T, error), ) (T, error)
RetryFetch calls fn up to maxAttempts times and returns the first success. It stops early if the context is done, since a retry cannot then succeed, or if retryable reports the error as permanent (a nil retryable retries every error). It does NOT sleep between attempts: each attempt is already bounded by its own timeout and the provisioning path wants fail-fast behavior.
Types ¶
type HTTPTransportOptions ¶
type HTTPTransportOptions struct {
// DialTimeout bounds the TCP connect.
DialTimeout time.Duration
// TLSHandshakeTimeout bounds the TLS handshake (ignored for plain-HTTP endpoints).
TLSHandshakeTimeout time.Duration
// ResponseHeaderTimeout bounds the wait for response headers after the request is written.
ResponseHeaderTimeout time.Duration
// TLSConfig is the TLS client config; nil for plain-HTTP endpoints (e.g. IMDS).
TLSConfig *tls.Config
// DialAddrOverride forces every dial to this host:port regardless of the URL host (the
// curl --resolve equivalent used by the LPS SNI-pin path). Empty means dial the URL host.
DialAddrOverride string
}
HTTPTransportOptions configures the base transport built by NewBaseTransport.