probe

package
v0.6.76 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0, Apache-2.0, MIT Imports: 4 Imported by: 0

Documentation

Overview

Package probe is the agent probe handoff between the deployment operator (internal/controller) and devbox-gateway (pkg/devbox/gateway/prober), section 4.2a of the DevBoxes plan.

The golden boot only runs the bootstrap script and mise; the agent probe runs once the golden tag exists, from an actor the gateway resumes from that tag, because only the gateway can reach a daemon (through atenet-router). The probe needs a box-scoped AI proxy token (console's mintDevboxProbeToken, which only the operator calls), so adapters that list models only when authenticated still work.

Contract, in the operator namespace:

ConfigMap devbox-probe-<runner>-r<revision> (ConfigMapName), one per revision:
  labels:  devboxes.plural.sh/probe=request, devboxes.plural.sh/runner=<runner>,
           devboxes.plural.sh/revision=<revision>
  data["request.json"]: Request, written by the operator. Its "probe" field is a protojson
                        devbox.v1.ProbeAgentsRequest without endpoints; the gateway fills them in.

Secret devbox-probe-tokens (TokenSecretName), shared by all requests:
  data[<ConfigMap name>]: Token as JSON. Request.TokenSecret names the Secret and key. The operator writes
                          the key before it creates the ConfigMap, re-mints it while the probe is pending
                          and the token is close to expiry, and deletes it with the ConfigMap. The gateway's
                          ServiceAccount may only get this one Secret.

The gateway watches pending ConfigMaps (no probe-state annotation). One replica claims a request with the probe-claim annotation ("<gateway id> <RFC 3339 time>", an optimistic update, so only one wins), registers the token with egress for a pseudo-instance, creates an actor in request.atespace from request.goldenTag, applies an egress policy that injects the token on the AI proxy host, calls Daemon.ProbeAgents, deletes the actor and writes back, in one update:

metadata.annotations["devboxes.plural.sh/probe-state"]: "done" or "failed"
data["result.json"]: protojson devbox.v1.ProbeAgentsResponse (when done)
data["error"]:       why the probe could not run (when failed; the gateway retries transient errors first)

A claim older than ClaimTTL is abandoned (its gateway died) and may be taken over.

Index

Constants

View Source
const (
	Label           = "devboxes.plural.sh/probe"
	LabelRequest    = "request"
	RunnerLabel     = "devboxes.plural.sh/runner"
	RevisionLabel   = "devboxes.plural.sh/revision"
	StateAnnotation = "devboxes.plural.sh/probe-state"
	ClaimAnnotation = "devboxes.plural.sh/probe-claim"
	StateDone       = "done"
	StateFailed     = "failed"
	RequestKey      = "request.json"
	ResultKey       = "result.json"
	ErrorKey        = "error"

	// TokenSecretName is the Secret holding every pending request's probe token, keyed by ConfigMap name.
	TokenSecretName = "devbox-probe-tokens"

	// ClaimTTL bounds how long a gateway may hold a claim without finishing.
	ClaimTTL = 20 * time.Minute
)

Variables

This section is empty.

Functions

func Claim

func Claim(holder string, at time.Time) string

Claim formats the claim annotation.

func ConfigMapName

func ConfigMapName(runner string, revision int64) string

ConfigMapName is the request ConfigMap of a runner revision, and the key of its token.

func ParseClaim

func ParseClaim(v string) (holder string, at time.Time, ok bool)

ParseClaim parses the claim annotation; ok is false for a missing or malformed claim.

Types

type Request

type Request struct {
	Runner        string `json:"runner"`
	Atespace      string `json:"atespace"`
	ActorTemplate string `json:"actorTemplate"`
	Revision      int64  `json:"revision"`
	GoldenTag     string `json:"goldenTag"`
	// DevboxID is the console Devbox the probe token is scoped to.
	DevboxID string `json:"devboxId"`
	// Probe is a protojson devbox.v1.ProbeAgentsRequest.
	Probe json.RawMessage `json:"probe,omitempty"`
	// TokenSecret locates the probe token.
	TokenSecret *TokenRef `json:"tokenSecret,omitempty"`
}

Request is request.json. The operator embeds it in its own type, which adds the declared agents.

type Token

type Token struct {
	Token     string    `json:"token"`
	ExpiresAt time.Time `json:"expiresAt"`
}

Token is one probe token as stored in TokenSecretName.

type TokenRef

type TokenRef struct {
	Name string `json:"name"`
	Key  string `json:"key"`
}

TokenRef names a key of TokenSecretName.

Jump to

Keyboard shortcuts

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