agents

package
v0.0.0-...-11c5079 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConversionNone = iota
	ConversionJsonToTelegrafToml
)

Variables

This section is empty.

Functions

func ConvertJsonToTelegrafToml

func ConvertJsonToTelegrafToml(configJson string, extraLabels map[string]string, interval int64) ([]byte, error)

func IsNoAppliedConfigs

func IsNoAppliedConfigs(err error) bool

IsNoAppliedConfigs tests if an error returned by a SpecificAgentRunner's ProcessConfig indicates no configs were applied

func SupportedAgents

func SupportedAgents() []telemetry_edge.AgentType

Types

type AgentRunningContext

type AgentRunningContext struct {
	sync.Mutex
	// contains filtered or unexported fields
}

AgentRunningContext encapsulates the state of a running agent process This should be created using CommandHandler's CreateContext

func (*AgentRunningContext) AppendEnv

func (c *AgentRunningContext) AppendEnv(envStrings ...string)

envStrings are strings in the format "foo=bar"

func (*AgentRunningContext) IsRunning

func (c *AgentRunningContext) IsRunning() bool

func (*AgentRunningContext) Pid

func (c *AgentRunningContext) Pid() int

type CommandHandler

type CommandHandler interface {
	CreateContext(ctx context.Context, agentType telemetry_edge.AgentType, cmdName string, workingDir string, arg ...string) *AgentRunningContext
	// StartAgentCommand will start the given command and optionally block until a specific phrase
	// is observed as given by the waitFor argument.
	// It will also setup "forwarding" of the command's stdout/err to logrus
	StartAgentCommand(runningContext *AgentRunningContext, agentType telemetry_edge.AgentType, waitFor string, waitForDuration time.Duration) error
	// WaitOnAgentCommand should be ran as a goroutine to watch for the agent process to end prematurely.
	// It will take care of restarting the agent via the SpecificAgentRunner's EnsureRunningState function.
	WaitOnAgentCommand(ctx context.Context, agentRunner SpecificAgentRunner, runningContext *AgentRunningContext)
	Signal(runningContext *AgentRunningContext, signal syscall.Signal) error
	Stop(runningContext *AgentRunningContext)
	// RunToCompletion combines the behavior (or equivalent thereof) of exec.Command with cmd.Output
	RunToCompletion(ctx context.Context, cmdName string, workingDir string, arg ...string) ([]byte, error)
}

CommandHandler abstracts access to an agent's process and managing its lifecycle and output

func NewCommandHandler

func NewCommandHandler() CommandHandler

type Conversion

type Conversion int

type FilebeatRunner

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

func (*FilebeatRunner) EnsureRunningState

func (fbr *FilebeatRunner) EnsureRunningState(ctx context.Context, _ bool)

func (*FilebeatRunner) Load

func (fbr *FilebeatRunner) Load(agentBasePath string) error

func (*FilebeatRunner) PostInstall

func (fbr *FilebeatRunner) PostInstall(string) error

func (*FilebeatRunner) ProcessConfig

func (fbr *FilebeatRunner) ProcessConfig(configure *telemetry_edge.EnvoyInstructionConfigure) error

func (*FilebeatRunner) ProcessTestMonitor

func (*FilebeatRunner) PurgeConfig

func (fbr *FilebeatRunner) PurgeConfig() error

func (*FilebeatRunner) SetCommandHandler

func (fbr *FilebeatRunner) SetCommandHandler(handler CommandHandler)

func (*FilebeatRunner) Stop

func (fbr *FilebeatRunner) Stop()

type OracleRunner

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

func (*OracleRunner) EnsureRunningState

func (o *OracleRunner) EnsureRunningState(ctx context.Context, applyConfigs bool)

func (*OracleRunner) Load

func (o *OracleRunner) Load(agentBasePath string) error

func (*OracleRunner) PostInstall

func (o *OracleRunner) PostInstall(string) error

func (*OracleRunner) ProcessConfig

func (o *OracleRunner) ProcessConfig(configure *telemetry_edge.EnvoyInstructionConfigure) error

func (*OracleRunner) ProcessTestMonitor

func (o *OracleRunner) ProcessTestMonitor(correlationId string, content string, timeout time.Duration) (*telemetry_edge.TestMonitorResults, error)

func (*OracleRunner) PurgeConfig

func (o *OracleRunner) PurgeConfig() error

func (*OracleRunner) SetCommandHandler

func (o *OracleRunner) SetCommandHandler(handler CommandHandler)

func (*OracleRunner) Stop

func (o *OracleRunner) Stop()

type PackagesAgentRunner

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

func (*PackagesAgentRunner) EnsureRunningState

func (pr *PackagesAgentRunner) EnsureRunningState(ctx context.Context, applyConfigs bool)

func (*PackagesAgentRunner) Load

func (pr *PackagesAgentRunner) Load(agentBasePath string) error

func (*PackagesAgentRunner) PostInstall

func (pr *PackagesAgentRunner) PostInstall(string) error

func (*PackagesAgentRunner) ProcessConfig

func (pr *PackagesAgentRunner) ProcessConfig(configure *telemetry_edge.EnvoyInstructionConfigure) error

func (*PackagesAgentRunner) ProcessTestMonitor

func (pr *PackagesAgentRunner) ProcessTestMonitor(correlationId string, content string, timeout time.Duration) (*telemetry_edge.TestMonitorResults, error)

func (*PackagesAgentRunner) PurgeConfig

func (pr *PackagesAgentRunner) PurgeConfig() error

func (*PackagesAgentRunner) SetCommandHandler

func (pr *PackagesAgentRunner) SetCommandHandler(handler CommandHandler)

func (*PackagesAgentRunner) Stop

func (pr *PackagesAgentRunner) Stop()

type Router

type Router interface {
	// Start ensures that when the ctx is done, then the managed SpecificAgentRunner instances will be stopped
	Start(ctx context.Context)
	ProcessInstall(install *telemetry_edge.EnvoyInstructionInstall)
	ProcessConfigure(configure *telemetry_edge.EnvoyInstructionConfigure)
	ProcessTestMonitor(testMonitor *telemetry_edge.EnvoyInstructionTestMonitor) *telemetry_edge.TestMonitorResults
}

Router routes external agent operations to the respective SpecificAgentRunner instance

func NewAgentsRunner

func NewAgentsRunner(detachChan <-chan struct{}) (Router, error)

NewAgentsRunner creates the component that manages the configuration and process lifecycle of the individual agents supported by the Envoy. The detachChan receives a signal when an attachment to an Ambassador is terminated. At that point this agents runner will take care of stopping any running agents and purging configuration in order to guarantee a consistent state at attachment.

type SpecificAgentRunner

type SpecificAgentRunner interface {
	// Load gets called after viper's configuration has been populated and before any other use.
	Load(agentBasePath string) error
	SetCommandHandler(handler CommandHandler)
	// EnsureRunningState is called after installation of an agent and after each call to ProcessConfig.
	// In the latter case, applyConfigs will be passed as true to indicate the runner should take
	// actions to reload configuration into an agent, if running.
	// It must ensure the agent process is running if configs and executable are available
	// It must also ensure that that the process is stopped if no configuration remains
	EnsureRunningState(ctx context.Context, applyConfigs bool)
	// PostInstall is invoked after installation of a new agent version and allows the
	// specific agent runner a chance to tweak capabilities assigned to the executable
	PostInstall(agentVersionPath string) error
	PurgeConfig() error
	ProcessConfig(configure *telemetry_edge.EnvoyInstructionConfigure) error
	ProcessTestMonitor(correlationId string, content string, timeout time.Duration) (*telemetry_edge.TestMonitorResults, error)
	// Stop should stop the agent's process, if running
	Stop()
}

SpecificAgentRunner manages the lifecyle and configuration of a single type of agent

type StandardAgentsRouter

type StandardAgentsRouter struct {
	DataPath string
	// contains filtered or unexported fields
}

func (*StandardAgentsRouter) ProcessConfigure

func (ar *StandardAgentsRouter) ProcessConfigure(configure *telemetry_edge.EnvoyInstructionConfigure)

func (*StandardAgentsRouter) ProcessInstall

func (ar *StandardAgentsRouter) ProcessInstall(install *telemetry_edge.EnvoyInstructionInstall)

func (*StandardAgentsRouter) ProcessTestMonitor

func (*StandardAgentsRouter) PurgeAgentConfigs

func (ar *StandardAgentsRouter) PurgeAgentConfigs() error

func (*StandardAgentsRouter) Start

func (ar *StandardAgentsRouter) Start(ctx context.Context)

type StandardCommandHandler

type StandardCommandHandler struct{}

func (*StandardCommandHandler) CreateContext

func (h *StandardCommandHandler) CreateContext(ctx context.Context, agentType telemetry_edge.AgentType, cmdName string, workingDir string, arg ...string) *AgentRunningContext

func (*StandardCommandHandler) RunToCompletion

func (h *StandardCommandHandler) RunToCompletion(ctx context.Context, cmdName string, workingDir string, arg ...string) ([]byte, error)

func (*StandardCommandHandler) Signal

func (h *StandardCommandHandler) Signal(runningContext *AgentRunningContext, signal syscall.Signal) error

func (*StandardCommandHandler) StartAgentCommand

func (h *StandardCommandHandler) StartAgentCommand(runningContext *AgentRunningContext, agentType telemetry_edge.AgentType, waitFor string, waitForDuration time.Duration) error

func (*StandardCommandHandler) Stop

func (*StandardCommandHandler) Stop(runningContext *AgentRunningContext)

func (*StandardCommandHandler) WaitOnAgentCommand

func (h *StandardCommandHandler) WaitOnAgentCommand(ctx context.Context, agentRunner SpecificAgentRunner, runningContext *AgentRunningContext)

type TelegrafRunner

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

func (*TelegrafRunner) EnsureRunningState

func (tr *TelegrafRunner) EnsureRunningState(ctx context.Context, applyConfigs bool)

func (*TelegrafRunner) Load

func (tr *TelegrafRunner) Load(agentBasePath string) error

func (*TelegrafRunner) PostInstall

func (tr *TelegrafRunner) PostInstall(agentVersionPath string) error

func (*TelegrafRunner) ProcessConfig

func (tr *TelegrafRunner) ProcessConfig(configure *telemetry_edge.EnvoyInstructionConfigure) error

func (*TelegrafRunner) ProcessTestMonitor

func (tr *TelegrafRunner) ProcessTestMonitor(correlationId string, content string, timeout time.Duration) (*telemetry_edge.TestMonitorResults, error)

func (*TelegrafRunner) PurgeConfig

func (tr *TelegrafRunner) PurgeConfig() error

func (*TelegrafRunner) SetCommandHandler

func (tr *TelegrafRunner) SetCommandHandler(handler CommandHandler)

func (*TelegrafRunner) Stop

func (tr *TelegrafRunner) Stop()

type TelegrafTestConfigRunner

type TelegrafTestConfigRunner interface {
	StartTestConfigServer(configToml []byte, configServerErrors chan error, listener net.Listener) io.Closer
	RunCommand(hostPort string, exePath string, basePath string, timeout time.Duration) ([]byte, error)
}

TelegrafTestConfigRunner encapsulates the process-spawning aspects of handling telegraf's --test mode of running a configuration one-shot

type TelegrafTestConfigRunnerBuilder

type TelegrafTestConfigRunnerBuilder func(testConfigServerId string, testConfigServerToken string) TelegrafTestConfigRunner

Jump to

Keyboard shortcuts

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