Documentation
¶
Overview ¶
Package toolboxhttp is the HTTP transport sandboxd uses to reach a sandbox's toolbox over the network.
Index ¶
Constants ¶
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).
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 ¶
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 DeadPeerTimeout ¶
DeadPeerTimeout is the current bound (0: off).
func DialContext ¶
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 ¶
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.