agent

package
v2.29.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: AGPL-3.0 Imports: 68 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolReconnectingPTY = "reconnecting-pty"
	ProtocolSSH             = "ssh"
	ProtocolDial            = "dial"
)
View Source
const (
	EnvProcPrioMgmt = "CODER_PROC_PRIO_MGMT"
	EnvProcOOMScore = "CODER_PROC_OOM_SCORE"
)

EnvProcPrioMgmt determines whether we attempt to manage process CPU and OOM Killer priority.

View Source
const EnvAgentSubsystem = "CODER_AGENT_SUBSYSTEM"

EnvAgentSubsystem is the environment variable used to denote the specialized environment in which the agent is running (e.g. envbox, envbuilder).

Variables

View Source
var WindowsDriveRegex = regexp.MustCompile(`^[a-zA-Z]:\\$`)

Functions

func PrometheusMetricsHandler added in v2.10.0

func PrometheusMetricsHandler(prometheusRegistry *prometheus.Registry, logger slog.Logger) http.Handler

func SSHKeySeed added in v2.22.0

func SSHKeySeed(userName, workspaceName, agentName string) (int64, error)

SSHKeySeed converts an owner userName, workspaceName and agentName to an int64 hash. This uses the FNV-1a hash algorithm which provides decent distribution and collision resistance for string inputs.

Why owner username, workspace name, and agent name? These are the components that are used in hostnames for the workspace over SSH, and so we want the workspace to have a stable key with respect to these. We don't use the respective UUIDs. The workspace UUID would be different if you delete and recreate a workspace with the same name. The agent UUID is regenerated on each build. Since Coder's Tailnet networking is handling the authentication, we should not be showing users warnings about host SSH keys.

Types

type Agent

type Agent interface {
	HTTPDebug() http.Handler
	// TailnetConn may be nil.
	TailnetConn() *tailnet.Conn
	io.Closer
}

func New

func New(options Options) Agent

type HTTPResponseCode added in v2.27.0

type HTTPResponseCode = int

type ListeningPortsGetter added in v2.29.0

type ListeningPortsGetter interface {
	GetListeningPorts() ([]codersdk.WorkspaceAgentListeningPort, error)
}

type Options

type Options struct {
	Filesystem             afero.Fs
	LogDir                 string
	TempDir                string
	ScriptDataDir          string
	Client                 Client
	ReconnectingPTYTimeout time.Duration
	EnvironmentVariables   map[string]string
	Logger                 slog.Logger
	// IgnorePorts tells the api handler which ports to ignore when
	// listing all listening ports. This is helpful to hide ports that
	// are used by the agent, that the user does not care about.
	IgnorePorts map[int]string
	// ListeningPortsGetter is used to get the list of listening ports. Only
	// tests should set this. If unset, a default that queries the OS will be used.
	ListeningPortsGetter         ListeningPortsGetter
	SSHMaxTimeout                time.Duration
	TailnetListenPort            uint16
	Subsystems                   []codersdk.AgentSubsystem
	PrometheusRegistry           *prometheus.Registry
	ReportMetadataInterval       time.Duration
	ServiceBannerRefreshInterval time.Duration
	BlockFileTransfer            bool
	Execer                       agentexec.Execer
	Devcontainers                bool
	DevcontainerAPIOptions       []agentcontainers.Option // Enable Devcontainers for these to be effective.
	Clock                        quartz.Clock
	SocketServerEnabled          bool
	SocketPath                   string // Path for the agent socket server socket
}

type PostWorkspaceAgentAppHealth

type PostWorkspaceAgentAppHealth func(context.Context, agentsdk.PostAppHealthsRequest) error

PostWorkspaceAgentAppHealth updates the workspace app health.

type WorkspaceAppHealthReporter

type WorkspaceAppHealthReporter func(ctx context.Context)

WorkspaceAppHealthReporter is a function that checks and reports the health of the workspace apps until the passed context is canceled.

func NewAppHealthReporterWithClock added in v2.13.0

func NewAppHealthReporterWithClock(
	logger slog.Logger,
	apps []codersdk.WorkspaceApp,
	postWorkspaceAgentAppHealth PostWorkspaceAgentAppHealth,
	clk quartz.Clock,
) WorkspaceAppHealthReporter

NewAppHealthReporterWithClock is only called directly by test code. Product code should call NewAppHealthReporter.

func NewWorkspaceAppHealthReporter

func NewWorkspaceAppHealthReporter(logger slog.Logger, apps []codersdk.WorkspaceApp, postWorkspaceAgentAppHealth PostWorkspaceAgentAppHealth) WorkspaceAppHealthReporter

NewWorkspaceAppHealthReporter creates a WorkspaceAppHealthReporter that reports app health to coderd.

Directories

Path Synopsis
acmock
Package acmock is a generated GoMock package.
Package acmock is a generated GoMock package.
dcspec
Package dcspec contains an automatically generated Devcontainer specification.
Package dcspec contains an automatically generated Devcontainer specification.
watcher
Package watcher provides file system watching capabilities for the agent.
Package watcher provides file system watching capabilities for the agent.
cmdtest command
immortalstreams
Package reaper contains logic for reaping subprocesses.
Package reaper contains logic for reaping subprocesses.

Jump to

Keyboard shortcuts

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