toolboxhttp

package
v0.6.11 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package toolboxhttp is the HTTP transport sandboxd uses to reach a sandbox's toolbox over the network.

Index

Constants

View Source
const DefaultDeadPeerTimeout = 30 * time.Second

DefaultDeadPeerTimeout is how long a toolbox connection to a sandbox that stopped answering lives on (SB_TOOLBOX_DEAD_PEER_TIMEOUT).

View Source
const MinDeadPeerTimeout = 6 * time.Second

MinDeadPeerTimeout is the smallest timeout SetDeadPeerTimeout takes: the kernel counts keepalive time in whole seconds, and the probe interval is a sixth of the timeout.

Variables

View Source
var Transport = func() *http.Transport {
	t := http.DefaultTransport.(*http.Transport).Clone()
	t.DisableKeepAlives = true
	t.DialContext = DialContext
	return t
}()

Transport never keeps a connection open between calls. A sandbox's address outlives it: the next sandbox on the same Firecracker TAP slot or container IP gets it, and a VM restarted or resumed there has a fresh kernel. A pooled keep-alive connection to the old sandbox would be sent to the new one and reset (live: 72 of 80 concurrent execs into a fresh Firecracker sandbox, and a quarter of a create/exec/destroy churn, failed with 502 "connection reset by peer"). A local handshake per call costs tens of microseconds. WebSocket upgrades are unaffected: Go never marks a protocol switch "Connection: close", and an upgraded connection is never pooled.

Functions

func Client

func Client(timeout time.Duration) *http.Client

Client is an http.Client over Transport (timeout 0: none).

func DeadPeerTimeout

func DeadPeerTimeout() time.Duration

DeadPeerTimeout is the current bound (0: off).

func DialContext

func DialContext(ctx context.Context, network, addr string) (net.Conn, error)

DialContext dials a toolbox. Every network path from sandboxd to a toolboxd uses it (Transport, and the SSH gateway's session WebSocket), so a sandbox that dies without closing its connections (a killed gVisor sandbox or Firecracker VM: nothing is left to send a FIN or a reset, and its address goes silent) is noticed within DeadPeerTimeout instead of when the kernel gives up, minutes later (live: an exec into a gVisor sandbox killed by a fork bomb answered 502 after 3m18s).

func SetDeadPeerTimeout

func SetDeadPeerTimeout(d time.Duration)

SetDeadPeerTimeout sets how long a connection whose sandbox stopped answering lives on; the daemon calls it once at boot. 0 turns the bound off (Go's default keepalive, about 2.5 minutes, and the kernel's retransmission limit, about 15 minutes). A positive value under MinDeadPeerTimeout is raised to it. It applies to connections dialed afterwards.

Types

This section is empty.

Jump to

Keyboard shortcuts

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