agent

package
v0.0.0-...-56cb166 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: AGPL-3.0 Imports: 113 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProductionMongoWriteConcern = true

ProductionMongoWriteConcern is provided to override in tests, default is true

Functions

func ConnectAsAgent

func ConnectAsAgent(ctx context.Context, a agent.Agent) (io.Closer, error)

ConnectAsAgent really connects to the API specified in the agent config. It's extracted so tests can pass something else in.

func DBReplMachineAgentFactoryFn

func DBReplMachineAgentFactoryFn(
	agentConfWriter agentconfig.AgentConfigWriter,
	newDBReplWorkerFunc dbreplaccessor.NewDBReplWorkerFunc,
) dbReplMachineAgentFactoryFnType

DBReplMachineAgentFactoryFn returns a function which instantiates a replMachineAgent given a machineId.

func MachineAgentFactoryFn

func MachineAgentFactoryFn(
	agentConfWriter agentconfig.AgentConfigWriter,
	bufferedLogger *logsender.BufferedLogWriter,
	newDBWorkerFunc dbaccessor.NewDBWorkerFunc,
	preUpgradeSteps PreUpgradeStepsFunc,
	upgradeSteps UpgradeStepsFunc,
	rootDir string,
) machineAgentFactoryFnType

MachineAgentFactoryFn returns a function which instantiates a MachineAgent given a machineId.

func NewCheckConnectionCommand

func NewCheckConnectionCommand(config agentconf.AgentConf, connect ConnectFunc) cmd.Command

NewCheckConnectionCommand returns a command that will test connecting to the API with details from the agent's config.

func NewDBReplAgentCommand

func NewDBReplAgentCommand(
	ctx *cmd.Context,
	replMachineAgentFactory dbReplMachineAgentFactoryFnType,
	agentInitializer AgentInitializer,
	configFetcher agentconfig.AgentConfigWriter,
) cmd.Command

NewDBReplAgentCommand creates a Command that handles parsing command-line arguments and instantiating and running a MachineAgent.

func NewMachineAgentCommand

func NewMachineAgentCommand(
	ctx *cmd.Context,
	machineAgentFactory machineAgentFactoryFnType,
	agentInitializer AgentInitializer,
	configFetcher agentconfig.AgentConfigWriter,
) cmd.Command

NewMachineAgentCommand creates a Command that handles parsing command-line arguments and instantiating and running a MachineAgent.

func NewREPLMachineAgent

func NewREPLMachineAgent(
	agentTag names.Tag,
	agentConfWriter agentconfig.AgentConfigWriter,
	runner *worker.Runner,
	newDBReplWorkerFunc dbreplaccessor.NewDBReplWorkerFunc,
	isCaasAgent bool,
) (*replMachineAgent, error)

NewREPLMachineAgent instantiates a new replMachineAgent.

func NewSafeModeAgentCommand

func NewSafeModeAgentCommand(
	ctx *cmd.Context,
	safeModeMachineAgentFactory safeModeMachineAgentFactoryFnType,
	agentInitializer AgentInitializer,
	configFetcher agentconfig.AgentConfigWriter,
) cmd.Command

NewSafeModeAgentCommand creates a Command that handles parsing command-line arguments and instantiating and running a MachineAgent.

func SafeModeMachineAgentFactoryFn

func SafeModeMachineAgentFactoryFn(
	agentConfWriter agentconfig.AgentConfigWriter,
	newDBWorkerFunc dbaccessor.NewDBWorkerFunc,
) safeModeMachineAgentFactoryFnType

SafeModeMachineAgentFactoryFn returns a function which instantiates a SafeModeMachineAgent given a machineId.

Types

type AgentInitializer

type AgentInitializer interface {
	AddFlags(*gnuflag.FlagSet)
	CheckArgs([]string) error
	// DataDir returns the directory where this agent should store its data.
	DataDir() string
}

AgentInitializer handles initializing a type for use as a Jujud agent.

type BootstrapCommand

type BootstrapCommand struct {
	cmd.CommandBase
	agentconf.AgentConf
	Timeout           time.Duration
	BootstrapAgent    BootstrapAgentFunc
	DqliteInitializer agentbootstrap.DqliteInitializerFunc
}

BootstrapCommand represents a jujud bootstrap command.

func NewBootstrapCommand

func NewBootstrapCommand() *BootstrapCommand

NewBootstrapCommand returns a new BootstrapCommand that has been initialized.

func (*BootstrapCommand) Info

func (c *BootstrapCommand) Info() *cmd.Info

Info returns a description of the command.

func (*BootstrapCommand) Init

func (c *BootstrapCommand) Init(args []string) error

Init initializes the command for running.

func (*BootstrapCommand) Run

func (c *BootstrapCommand) Run(ctx *cmd.Context) error

Run initializes state for an environment.

func (*BootstrapCommand) SetFlags

func (c *BootstrapCommand) SetFlags(f *gnuflag.FlagSet)

SetFlags adds the flags for this command to the passed gnuflag.FlagSet.

type CommandRunner

type CommandRunner interface {
	RunCommands(run exec.RunParams) (*exec.ExecResponse, error)
}

CommandRunner allows to run commands on the underlying system

type ConnectFunc

type ConnectFunc func(context.Context, agent.Agent) (io.Closer, error)

ConnectFunc connects to the API as the given agent.

type MachineAgent

type MachineAgent struct {
	agentconfig.AgentConfigWriter
	// contains filtered or unexported fields
}

MachineAgent is responsible for tying together all functionality needed to orchestrate a Jujud instance which controls a machine.

func NewMachineAgent

func NewMachineAgent(
	agentTag names.Tag,
	agentConfWriter agentconfig.AgentConfigWriter,
	bufferedLogger *logsender.BufferedLogWriter,
	runner *worker.Runner,
	loopDeviceManager looputil.LoopDeviceManager,
	newDBWorkerFunc dbaccessor.NewDBWorkerFunc,
	preUpgradeSteps PreUpgradeStepsFunc,
	upgradeSteps UpgradeStepsFunc,
	rootDir string,
	isCaasAgent bool,
) (*MachineAgent, error)

NewMachineAgent instantiates a new MachineAgent.

func (*MachineAgent) ChangeConfig

func (a *MachineAgent) ChangeConfig(mutate agent.ConfigMutator) error

func (*MachineAgent) Done

func (a *MachineAgent) Done(err error)

Done signals the machine agent is finished

func (*MachineAgent) Restart

func (a *MachineAgent) Restart() error

Restart restarts the agent's service.

func (*MachineAgent) Run

func (a *MachineAgent) Run(ctx *cmd.Context) (err error)

Run runs a machine agent.

func (*MachineAgent) Stop

func (a *MachineAgent) Stop() error

Stop stops the machine agent.

func (*MachineAgent) Tag

func (a *MachineAgent) Tag() names.Tag

func (*MachineAgent) Wait

func (a *MachineAgent) Wait() error

Wait waits for the machine agent to finish.

func (*MachineAgent) WorkersStarted

func (a *MachineAgent) WorkersStarted() <-chan struct{}

WorkersStarted returns a channel that's closed once all top level workers have been started. This is provided for testing purposes.

type ModelMetrics

type ModelMetrics interface {
	ForModel(model names.ModelTag) dependency.Metrics
}

ModelMetrics defines a type for creating metrics for a given model.

type PreUpgradeStepsFunc

type PreUpgradeStepsFunc func(state.ModelType) upgrades.PreUpgradeStepsFunc

The following allows the upgrade steps to be overridden by brittle integration tests.

type SafeModeMachineAgent

type SafeModeMachineAgent struct {
	agentconfig.AgentConfigWriter
	// contains filtered or unexported fields
}

SafeModeMachineAgent is responsible for tying together all functionality needed to orchestrate a Jujud instance which controls a machine.

func NewSafeModeMachineAgent

func NewSafeModeMachineAgent(
	agentTag names.Tag,
	agentConfWriter agentconfig.AgentConfigWriter,
	runner *worker.Runner,
	newDBWorkerFunc dbaccessor.NewDBWorkerFunc,
	isCaasAgent bool,
) (*SafeModeMachineAgent, error)

NewSafeModeMachineAgent instantiates a new SafeModeMachineAgent.

func (*SafeModeMachineAgent) ChangeConfig

func (a *SafeModeMachineAgent) ChangeConfig(mutate agent.ConfigMutator) error

func (*SafeModeMachineAgent) Done

func (a *SafeModeMachineAgent) Done(err error)

Done signals the safe mode machine agent is finished

func (*SafeModeMachineAgent) Run

func (a *SafeModeMachineAgent) Run(ctx *cmd.Context) (err error)

Run runs a safe mode machine agent.

func (*SafeModeMachineAgent) Stop

func (a *SafeModeMachineAgent) Stop() error

Stop stops the safe mode machine agent.

func (*SafeModeMachineAgent) Tag

func (a *SafeModeMachineAgent) Tag() names.Tag

func (*SafeModeMachineAgent) Wait

func (a *SafeModeMachineAgent) Wait() error

Wait waits for the safe mode machine agent to finish.

type UpgradeStepsFunc

type UpgradeStepsFunc = upgrades.UpgradeStepsFunc

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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