agent

package
v0.0.0-...-2fc0378 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 72 Imported by: 9

Documentation

Overview

Package agent runs tasks on differents runtime environments, such as hosts and containers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

Agent manages the data necessary to run tasks in a runtime environment.

func New

func New(ctx context.Context, opts Options, serverURL string) (*Agent, error)

New creates a new Agent with some Options and a client.Communicator. Call the Agent's Start method to begin listening for tasks to run. Users should call Close when the agent is finished.

func (*Agent) Close

func (a *Agent) Close(ctx context.Context)

func (*Agent) GetSender

func (a *Agent) GetSender(ctx context.Context, output globals.LogOutputType, prefix string, taskID string, taskExecution int) (send.Sender, error)

GetSender configures the agent's local logging, which can go to Splunk, a file, or stdout.

func (*Agent) SetDefaultLogger

func (a *Agent) SetDefaultLogger(sender send.Sender)

func (*Agent) SetHomeDirectory

func (a *Agent) SetHomeDirectory(ctx context.Context)

SetHomeDirectory sets the agent's home directory to the user's home directory if it is not already set.

func (*Agent) Start

func (a *Agent) Start(ctx context.Context) error

Start starts the agent loop. The agent polls the API server for new tasks at interval agentSleepInterval and runs them.

type ContainerHandle

type ContainerHandle interface {
	GetID() string
	GetName() string
	GetEnvFileHostDir() string
	Destroy(ctx context.Context) error
}

ContainerHandle is the interface through which the agent manages an active task isolation container. Using an interface lets unit tests inject a fake without requiring a live Docker daemon.

type Options

type Options struct {
	// Mode determines which mode the agent will run in.
	Mode globals.Mode
	// HostID and HostSecret only apply in host mode.
	HostID                 string
	HostSecret             string
	StatusPort             int
	LogPrefix              string
	LogOutput              globals.LogOutputType
	WorkingDirectory       string
	HeartbeatInterval      time.Duration
	Cleanup                bool
	SetupData              apimodels.AgentSetupData
	CloudProvider          string
	TraceCollectorEndpoint string
	// SendTaskLogsToGlobalSender indicates whether task logs should also be
	// sent to the global agent file log.
	SendTaskLogsToGlobalSender bool
	HomeDirectory              string
	SingleTaskDistro           bool
	// ContainerRetainOnFailureSecs is how long an isolation container is kept
	// alive after a task failure so on-call can docker exec into it for
	// post-mortem inspection. Zero disables retention.
	ContainerRetainOnFailureSecs int
	// CompatClientPath is the absolute path to the legacy ~/evergreen binary,
	// mounted read-only into isolation containers.
	CompatClientPath string
}

Options contains startup options for an Agent.

func (*Options) AddLoggableInfo

func (o *Options) AddLoggableInfo(msg message.Fields) message.Fields

AddLoggableInfo is a helper to add relevant information about the agent runtime to the log message. This is typically to make high priority error logs more informative.

type StatsCollector

type StatsCollector struct {

	// Cmds are agent-fixed host diagnostics, never task-controlled.
	Cmds []string
	// PSCmd is the task-configurable ps command. It runs inside the task's
	// isolation container when one exists because its value is
	// author-controlled.
	PSCmd string
	// Container fields locate the task's isolation container, used only to
	// run PSCmd.
	ContainerID    string
	WorkDir        string
	EnvFileHostDir string
	ExecUser       string
	// indicates the sampling frequency
	Interval time.Duration
	// contains filtered or unexported fields
}

StatsCollector samples machine statistics and logs them back to the API server at regular intervals.

func NewSimpleStatsCollector

func NewSimpleStatsCollector(logger client.LoggerProducer, jpm jasper.Manager, interval time.Duration, cmds ...string) *StatsCollector

NewSimpleStatsCollector creates a StatsCollector that runs the given commands at the given interval and sends the results to the given logger.

Directories

Path Synopsis
Package command defines the behavior of commands invoked by project configuration files.
Package command defines the behavior of commands invoked by project configuration files.
taskoutput
Task Output Directory
Task Output Directory
Package util provides utility methods for the agent.
Package util provides utility methods for the agent.

Jump to

Keyboard shortcuts

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