Documentation
¶
Overview ¶
Package ssh is the fixed-capacity provider (providers delta C): jobs run on one host the owner already has, reached over the system OpenSSH client, with a number of slots instead of a price.
Index ¶
- Variables
- func CheckTunnelSshd(out string) []provider.DoctorLine
- func GitFloorLine(version, changelog string) provider.DoctorLine
- func KnownHostsLine(hostKey string) string
- func ParseHostKey(s string) (typ string, err error)
- func ParseResourceID(id string) (host string, slots []int, name string, ok bool)
- func ResourceID(host string, slots []int, name string) string
- func SlotsArg(slots []int) string
- type Class
- type Lease
- type Parsed
- type Provider
- func (p *Provider) DoctorLines(ctx context.Context) []provider.DoctorLine
- func (p *Provider) Estimate(_ context.Context, j *provider.JobSpec) (config.Micros, error)
- func (p *Provider) Fetch(ctx context.Context, h provider.Handle, a provider.ArtifactSpec, w io.Writer) error
- func (p *Provider) Info() provider.Info
- func (p *Provider) Launch(ctx context.Context, j *provider.JobSpec) (provider.Handle, error)
- func (p *Provider) List(ctx context.Context, prefixes []string) ([]provider.Resource, error)
- func (p *Provider) Output(ctx context.Context, h provider.Handle, s provider.Stream, off int64, ...) error
- func (p *Provider) Owner(ctx context.Context, id string) (string, error)
- func (p *Provider) Preflight(_ context.Context, j *provider.JobSpec) error
- func (p *Provider) SlotStatus(ctx context.Context) (provider.SlotStatus, error)
- func (p *Provider) Spend(context.Context) (config.Micros, error)
- func (p *Provider) Start(_ context.Context, rt provider.Runtime) error
- func (p *Provider) SweepRules() provider.SweepPolicy
- func (p *Provider) Teardown(ctx context.Context, id string) error
- func (p *Provider) Watch(ctx context.Context, h provider.Handle, out provider.Sink) (provider.Result, error)
- type Result
- type Settings
- type Size
- type SlotLocks
- type TailExitError
Constants ¶
This section is empty.
Variables ¶
var ( // AgentSpec builds the agent's spec from the job. AgentSpec func(j *provider.JobSpec) agent.Spec // ResolveAgentFile returns the sha256 and local path of the agent binary for an architecture: // its bytes are what the provider sends over the session (providers delta C.4 item 4). ResolveAgentFile func(e *config.Effective, core *config.Provider, arch string) (sha, path string, err error) )
The orchestration sets these (as RunPod's and Sprites' AgentSpec).
var ErrStreamEnded = &provider.ErrTransient{Why: "tail stream ended without a done frame"}
ErrStreamEnded: the tail's session ended before the agent's done frame (a dropped link); the caller reopens it from the last offsets.
Functions ¶
func CheckTunnelSshd ¶
func CheckTunnelSshd(out string) []provider.DoctorLine
CheckTunnelSshd judges the output of `sshd -T` for the tunnel account: one fail line per option that is not as C.6.3 wants it, else a single ok line.
func GitFloorLine ¶
func GitFloorLine(version, changelog string) provider.DoctorLine
GitFloorLine judges the host's `git --version` output and the part of its package changelog that names the CVE (empty when the package has none): ok at git >= 2.45.1 or when the changelog names CVE-2024-32002, else a fail line `ssh-git`.
func KnownHostsLine ¶
KnownHostsLine is the one line of the pinned known_hosts file: `bitc-ssh <type> <key>`. The alias makes it independent of the host and port (providers delta C.2.2).
func ParseHostKey ¶
ParseHostKey checks the host_key of the host file: an authorized_keys-style line (the type, the base64 blob, an optional comment). It returns the key type, or the reason it is not usable (providers delta C.10): ssh-dss and ssh-rsa under 3072 bits are refused.
func ParseResourceID ¶
ParseResourceID splits a resource id: the slots must ascend, each in 1..64.
func ResourceID ¶
ResourceID is <host>/s<i>[+s<j>...]/<name> (providers delta C.3.5).
Types ¶
type Class ¶
type Class int
Class is what the ssh client's stderr says about how far a session got.
func ClassifyLoose ¶
ClassifyLoose is for the steps before the resource point, where nothing of this job exists on the host: the whitelisted line may sit among others (the host-key mismatch prints a banner).
func ClassifySession ¶
ClassifySession matches the client's result against the pre-session whitelist of providers delta C.5.1 item 3: only exit 255 with stderr that is exactly one of the listed lines (with LogLevel=ERROR) proves that no channel and no request existed. Anything else, a second line or other text included, is ClassOther: the session may have been up.
type Lease ¶
type Lease struct {
Slots []int
// contains filtered or unexported fields
}
Lease is a set of held slot locks.
type Parsed ¶
Parsed are the fields of a resource name (<prefix>-<install16>-<pool>-<size>-<job8>-<E>).
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is the ssh provider: slots on one host the owner already has (providers delta C).
func NewProvider ¶
NewProvider builds the provider from its host section.
func (*Provider) DoctorLines ¶
func (p *Provider) DoctorLines(ctx context.Context) []provider.DoctorLine
DoctorLines are the provider's own `doctor --remote` checks (providers delta C.8): the pinned key, the host's arch and slots, every item of `check-host --doctor` (relayed as the host prints it) and the tunnel account.
func (*Provider) Estimate ¶
Estimate is usd_per_hour x (E - now), which is $0 by default (providers delta C.3.3).
func (*Provider) Fetch ¶
func (p *Provider) Fetch(ctx context.Context, h provider.Handle, a provider.ArtifactSpec, w io.Writer) error
Fetch downloads artifacts.tar.gz from a.Offset over exec, capped (resumable by offset).
func (*Provider) Launch ¶
Launch leases slots, checks the host, prepares the slots and attaches (providers delta C.5):
slot locks; probe; install; check-host; `slot-boot --prepare` (the resource point); then `slot-boot --run`, the one call that carries job input (the attach point).
Everything before --prepare leaves nothing on the host (provider.Unmade). A --prepare that never got past session setup is the same; any other --prepare failure is an ErrPreAttach naming the slot group. A --run that never got past session setup is an ErrPreAttach too; every other --run outcome without the `started` ack is attached, and nothing falls back after it.
func (*Provider) List ¶
List lists the slot groups that carry a name with one of the prefixes: one Resource per group. Its ID is <host>/s<i>[+s<j>]/<name>; a failure is a refusal of the launch (providers delta C.3.3).
func (*Provider) Output ¶
func (p *Provider) Output(ctx context.Context, h provider.Handle, s provider.Stream, off int64, w io.Writer) error
Output copies a result file from off (spec 8.4 "Host side"), over exec.
func (*Provider) Owner ¶
Owner returns the owner tag the slot's owner file carries, "" for a slot group that is free or whose tag is another install's: the proof is the tag itself (HMAC of the name).
func (*Provider) Preflight ¶
Preflight is the network-free eligibility check (providers delta C.5): a size of this host, no services and no root steps (decision 15), a deploy key for a private repo, a payload that fits.
func (*Provider) SlotStatus ¶
SlotStatus lists the slot groups held now, by any controller (the lease is ahead), for `status`.
func (*Provider) Start ¶
Start keeps the host's redactor, so the deploy key joins it (Walk calls Start once).
func (*Provider) SweepRules ¶
func (p *Provider) SweepRules() provider.SweepPolicy
SweepRules: a slot group is one resource per job (providers delta C.3.6). An own group with no live reservation on this host is freed once its lease is older than start_timeout, an own group whose only reservation is an orphan at once, and any own group past E; the owner tag must verify (the shared sweep checks it). The agent frees its own slot at D + 10m, so the timer is advised (doctor warns), not mandatory.
func (*Provider) Teardown ¶
Teardown frees the slots of a group by name (providers delta C.3.6): the host compares the owner file's name with name under the slots' mutex, so a stale cleanup never touches a later job that leased the same slot. The controller's slot locks are released whatever the answer.
func (*Provider) Watch ¶
func (p *Provider) Watch(ctx context.Context, h provider.Handle, out provider.Sink) (provider.Result, error)
Watch follows the job until its EXIT marker and the end of the agent (spec 8.4 host side). A dropped tail is not an error: it is reopened from the last offsets, and when reopening fails twice within 30 s the files are read every 5 s until a reopen succeeds.
type Result ¶
type Result struct {
Code int
Stderr string // the last 64 KiB: everything the ssh client itself printed
}
Result is one finished call of the host's gate.
type Settings ¶
type Settings struct {
Host, User, HostKey, HostKeyType, IdentityFile, Arch, Resolver string
Port, Slots int
USDPerHour config.Micros // accounting only
ConnectTimeout time.Duration
MemoryPerSlot config.Size // 0: no memory.max
Netns bool
Sizes map[string]Size
}
Settings are the provider-specific keys of [providers.ssh] (providers delta C.2), decoded.
func DecodeSettings ¶
DecodeSettings decodes the provider-specific keys strictly and applies the checks of providers delta C.10. It also reads the core fields the rules depend on (max_live, daily_usd, api_key). Each message is the text after `providers.ssh.`.
func (Settings) Argv ¶
Argv is everything after the program name of one ssh invocation (providers delta C.2.2): the host key is pinned (StrictHostKeyChecking=yes, a dedicated known_hosts file with one aliased line, no global file, no key update), no agent or other forwarding is ever requested, only the one identity file is offered, nothing prompts, and the connect has a timeout. No secret is in it: identity is a path. verb is the gate's command line (one argument).
type Size ¶
type Size struct{ Slots int }
Size is one entry of [providers.ssh] sizes: how many slots a job of that size takes.
type SlotLocks ¶
SlotLocks are the controller-side slot flocks, ACCOUNT/remote/ssh/slot.<i>.lock (providers delta C.3.1). A job's process holds them for its ssh attempt only; the host-side lease (the owner file) is the other half and guards a second controller and a dead one.
type TailExitError ¶
type TailExitError struct{ Code int }
TailExitError: `agent tail` ended with a nonzero exit status (66: the job's directory is not there yet, which the first tail after the attach can meet). It is transient.
func (*TailExitError) As ¶
func (e *TailExitError) As(target any) bool
func (*TailExitError) Error ¶
func (e *TailExitError) Error() string
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package sshfake is the ssh provider's test double (providers delta C.11): a fake host gate.
|
Package sshfake is the ssh provider's test double (providers delta C.11): a fake host gate. |
|
gate
command
Command sshfakegate is the fake ssh host gate the conformance suite runs in place of ssh (providers delta C.11): `sshfakegate --root DIR -- <gate command line>`.
|
Command sshfakegate is the fake ssh host gate the conformance suite runs in place of ssh (providers delta C.11): `sshfakegate --root DIR -- <gate command line>`. |