Documentation ¶
Index ¶
- Constants
- Variables
- func Manifold(config ManifoldConfig) dependency.Manifold
- func NewPebblePoller(logger Logger, clock clock.Clock, containerNames []string, ...) worker.Worker
- func NewRunListenerWrapper(rl *RunListener, logger Logger) worker.Worker
- func NewUniterResolver(cfg ResolverConfig) resolver.Resolver
- func NewUpdateStatusTimer() remotestate.UpdateStatusTimerFunc
- func StartUniter(runner *worker.Runner, params *UniterParams) error
- func TranslateFortressErrors(err error) error
- type ChannelCommandRunner
- type ChannelCommandRunnerConfig
- type CommandRunner
- type JujuExecServer
- type Logger
- type ManifoldConfig
- type NewOperationExecutorFunc
- type NewPebbleClientFunc
- type NewRunnerExecutorFunc
- type Paths
- func (paths Paths) ComponentDir(name string) string
- func (paths Paths) GetBaseDir() string
- func (paths Paths) GetCharmDir() string
- func (paths Paths) GetJujucClientSocket(remote bool) sockets.Socket
- func (paths Paths) GetJujucServerSocket(remote bool) sockets.Socket
- func (paths Paths) GetMetricsSpoolDir() string
- func (paths Paths) GetToolsDir() string
- type PebbleClient
- type Probe
- type ProviderIDGetter
- type RebootQuerier
- type RemoteInitFunc
- type ResolverConfig
- type RunCommandsArgs
- type RunListener
- func (r *RunListener) Close() error
- func (r *RunListener) RegisterRunner(unitName string, runner CommandRunner)
- func (r *RunListener) Run() (err error)
- func (r *RunListener) RunCommands(args RunCommandsArgs) (results *exec.ExecResponse, err error)
- func (r *RunListener) UnregisterRunner(unitName string)
- type RuntimePaths
- type SocketConfig
- type SocketPair
- type StatePaths
- type Uniter
- type UniterExecutionObserver
- type UniterParams
Constants ¶
const JujuExecEndpoint = "JujuExecServer.RunCommands"
Variables ¶
var ( // ErrCAASUnitDead is the error returned from terminate or init // if the unit is Dead. ErrCAASUnitDead = errors.New("unit dead") )
Functions ¶
func Manifold ¶
func Manifold(config ManifoldConfig) dependency.Manifold
Manifold returns a dependency manifold that runs a uniter worker, using the resource names defined in the supplied config.
func NewPebblePoller ¶
func NewPebblePoller(logger Logger, clock clock.Clock, containerNames []string, workloadEventChan chan string, workloadEvents container.WorkloadEvents, newPebbleClient NewPebbleClientFunc) worker.Worker
NewPebblePoller starts a worker that polls the pebble interfaces of the supplied container list.
func NewRunListenerWrapper ¶
func NewRunListenerWrapper(rl *RunListener, logger Logger) worker.Worker
NewRunListenerWrapper returns a worker that will Close the supplied run listener when the worker is killed. The Wait() method will never return an error -- NewRunListener just drops the Run error on the floor and that's not what I'm fixing here.
func NewUniterResolver ¶
func NewUniterResolver(cfg ResolverConfig) resolver.Resolver
NewUniterResolver returns a new resolver.Resolver for the uniter.
func NewUpdateStatusTimer ¶
func NewUpdateStatusTimer() remotestate.UpdateStatusTimerFunc
NewUpdateStatusTimer returns a func returning timed signal suitable for update-status hook.
func StartUniter ¶
func StartUniter(runner *worker.Runner, params *UniterParams) error
StartUniter creates a new Uniter and starts it using the specified runner.
func TranslateFortressErrors ¶
TranslateFortressErrors turns errors returned by dependent manifolds due to fortress lockdown (i.e. model migration) into an error which causes the resolver loop to be restarted. When this happens the uniter is about to be shut down anyway.
Types ¶
type ChannelCommandRunner ¶
type ChannelCommandRunner struct {
// contains filtered or unexported fields
}
ChannelCommandRunner is a CommandRunner that registers command arguments in a runcommands.Commands, sends the returned IDs to a channel and waits for response callbacks.
func NewChannelCommandRunner ¶
func NewChannelCommandRunner(cfg ChannelCommandRunnerConfig) (*ChannelCommandRunner, error)
NewChannelCommandRunner returns a new ChannelCommandRunner with the given configuration.
func (*ChannelCommandRunner) RunCommands ¶
func (c *ChannelCommandRunner) RunCommands(args RunCommandsArgs) (results *exec.ExecResponse, err error)
RunCommands executes the supplied run commands by registering the arguments in a runcommands.Commands, and then sending the returned ID to a channel and waiting for a response callback.
type ChannelCommandRunnerConfig ¶
type ChannelCommandRunnerConfig struct { // Abort is a channel that will be closed when the runner should abort // the execution of run commands. Abort <-chan struct{} // Commands is used to add commands received from the listener. Commands runcommands.Commands // CommandChannel will be sent the IDs of commands added to Commands. CommandChannel chan<- string }
ChannelCommandRunnerConfig contains the configuration for a ChannelCommandRunner.
func (ChannelCommandRunnerConfig) Validate ¶
func (cfg ChannelCommandRunnerConfig) Validate() error
type CommandRunner ¶
type CommandRunner interface {
RunCommands(RunCommandsArgs RunCommandsArgs) (results *exec.ExecResponse, err error)
}
A CommandRunner is something that will actually execute the commands and return the results of that execution in the exec.ExecResponse (which contains stdout, stderr, and return code).
type JujuExecServer ¶
type JujuExecServer struct {
// contains filtered or unexported fields
}
The JujuExecServer is the entity that has the methods that are called over the rpc connection.
func (*JujuExecServer) RunCommands ¶
func (r *JujuExecServer) RunCommands(args RunCommandsArgs, result *exec.ExecResponse) error
RunCommands delegates the actual running to the runner and populates the response structure.
type Logger ¶
type Logger interface { Errorf(string, ...interface{}) Warningf(string, ...interface{}) Infof(string, ...interface{}) Debugf(string, ...interface{}) Tracef(string, ...interface{}) Child(string) loggo.Logger }
Logger represents the methods used for logging messages.
type ManifoldConfig ¶
type ManifoldConfig struct { AgentName string ModelType model.ModelType APICallerName string MachineLock machinelock.Lock Clock clock.Clock LeadershipTrackerName string CharmDirName string HookRetryStrategyName string TranslateResolverErr func(error) error Logger Logger Embedded bool EnforcedCharmModifiedVersion int ContainerNames []string }
ManifoldConfig defines the names of the manifolds on which a Manifold will depend.
func (*ManifoldConfig) Validate ¶
func (config *ManifoldConfig) Validate() error
Validate ensures all the required values for the config are set.
type NewOperationExecutorFunc ¶
NewOperationExecutorFunc is a func which returns an operations.Executor.
type NewPebbleClientFunc ¶
type NewPebbleClientFunc func(*client.Config) PebbleClient
NewPebbleClientFunc is the function type used to create a PebbleClient.
type NewRunnerExecutorFunc ¶
type NewRunnerExecutorFunc func(ProviderIDGetter, Paths) runner.ExecFunc
NewRunnerExecutorFunc defines the type of the NewRunnerExecutor.
type Paths ¶
type Paths struct { // ToolsDir is the directory containing the jujud executable running this // process; and also containing jujuc tool symlinks to that executable. It's // the only path in this struct that is not typically pointing inside the // directory reserved for the exclusive use of this worker (typically // /var/lib/juju/agents/$UNIT_TAG/ ) ToolsDir string // Runtime represents the set of paths that are relevant at runtime. Runtime RuntimePaths // State represents the set of paths that hold persistent local state for // the uniter. State StatePaths }
Paths represents the set of filesystem paths a uniter worker has reason to care about.
func NewPaths ¶
func NewPaths(dataDir string, unitTag names.UnitTag, socketConfig *SocketConfig) Paths
NewPaths returns the set of filesystem paths that the supplied unit should use, given the supplied root juju data directory path. If socketConfig is specified, all sockets will be TLS over TCP.
func NewWorkerPaths ¶
func NewWorkerPaths(dataDir string, unitTag names.UnitTag, worker string, socketConfig *SocketConfig) Paths
NewWorkerPaths returns the set of filesystem paths that the supplied unit worker should use, given the supplied root juju data directory path and worker identifier. Distinct worker identifiers ensure that runtime paths of different worker do not interfere. If socketConfig is specified, all sockets will be TLS over TCP.
func (Paths) ComponentDir ¶
ComponentDir returns the filesystem path to the directory containing all data files for a component.
func (Paths) GetBaseDir ¶
GetBaseDir exists to satisfy the context.Paths interface.
func (Paths) GetCharmDir ¶
GetCharmDir exists to satisfy the context.Paths interface.
func (Paths) GetJujucClientSocket ¶
GetJujucClientSocket exists to satisfy the context.Paths interface.
func (Paths) GetJujucServerSocket ¶
GetJujucServerSocket exists to satisfy the context.Paths interface.
func (Paths) GetMetricsSpoolDir ¶
GetMetricsSpoolDir exists to satisfy the runner.Paths interface.
func (Paths) GetToolsDir ¶
GetToolsDir exists to satisfy the context.Paths interface.
type PebbleClient ¶
PebbleClient describes the subset of github.com/canonical/pebble/client.Client that we need for the PebblePoller.
type Probe ¶
type Probe struct {
// contains filtered or unexported fields
}
func (*Probe) HasStarted ¶
func (*Probe) SetHasStarted ¶
func (p *Probe) SetHasStarted()
type ProviderIDGetter ¶
ProviderIDGetter defines the API to get provider ID.
type RebootQuerier ¶
RebootQuerier is implemented by types that can deliver one-off machine reboot notifications to entities.
type RemoteInitFunc ¶
type RemoteInitFunc func(remotestate.ContainerRunningStatus, <-chan struct{}) error
RemoteInitFunc is used to init remote state
type ResolverConfig ¶
type ResolverConfig struct { ModelType model.ModelType ClearResolved func() error ReportHookError func(hook.Info) error ShouldRetryHooks bool StartRetryHookTimer func() StopRetryHookTimer func() VerifyCharmProfile resolver.Resolver UpgradeSeries resolver.Resolver Reboot resolver.Resolver Leadership resolver.Resolver Actions resolver.Resolver CreatedRelations resolver.Resolver Relations resolver.Resolver Storage resolver.Resolver Commands resolver.Resolver OptionalResolvers []resolver.Resolver Logger Logger }
ResolverConfig defines configuration for the uniter resolver.
type RunCommandsArgs ¶
type RunCommandsArgs struct { // Commands is the arbitrary commands to execute on the unit Commands string // RelationId is the relation context to execute the commands in. RelationId int // RemoteUnitName is the remote unit for the relation context. RemoteUnitName string // RemoteUnitName is the remote unit for the relation context. RemoteApplicationName string // ForceRemoteUnit skips relation membership and existence validation. ForceRemoteUnit bool // UnitName is the unit for which the command is being run. UnitName string // Token is the unit token when run under CAAS environments for auth. Token string // Operator is true when the command should be run on the operator. // This only affects k8s workload charms. Operator bool }
RunCommandsArgs stores the arguments for a RunCommands call.
type RunListener ¶
type RunListener struct {
// contains filtered or unexported fields
}
RunListener is responsible for listening on the network connection and setting up the rpc server on that net connection. Also starts the go routine that listens and hands off the work.
func NewRunListener ¶
func NewRunListener(socket sockets.Socket, logger Logger) (*RunListener, error)
NewRunListener returns a new RunListener that is listening on given socket or named pipe passed in. If a valid RunListener is returned, is has the go routine running, and should be closed by the creator when they are done with it.
func (*RunListener) Close ¶
func (r *RunListener) Close() error
Close immediately stops accepting connections, and blocks until all existing connections have been closed.
func (*RunListener) RegisterRunner ¶
func (r *RunListener) RegisterRunner(unitName string, runner CommandRunner)
RegisterRunner registers a command runner for a given unit.
func (*RunListener) Run ¶
func (r *RunListener) Run() (err error)
Run accepts new connections until it encounters an error, or until Close is called, and then blocks until all existing connections have been closed.
func (*RunListener) RunCommands ¶
func (r *RunListener) RunCommands(args RunCommandsArgs) (results *exec.ExecResponse, err error)
RunCommands executes the supplied commands in a hook context.
func (*RunListener) UnregisterRunner ¶
func (r *RunListener) UnregisterRunner(unitName string)
UnregisterRunner unregisters a command runner for a given unit.
type RuntimePaths ¶
type RuntimePaths struct { // LocalJujuExecSocket listens for juju-exec invocations, and is always // active. LocalJujuExecSocket SocketPair // RemoteJujuExecSocket listens for remote juju-exec invocations. RemoteJujuExecSocket SocketPair // JujucServerSocket listens for jujuc invocations, and is only // active when supporting a jujuc execution context. LocalJujucServerSocket SocketPair // RemoteJujucServerSocket listens for remote jujuc invocations, and is only // active when supporting a jujuc execution context. RemoteJujucServerSocket SocketPair }
RuntimePaths represents the set of paths that are relevant at runtime.
type SocketConfig ¶
SocketConfig specifies information for remote sockets.
type SocketPair ¶
SocketPair is a server+client pair of socket descriptors.
type StatePaths ¶
type StatePaths struct { // BaseDir is the unit agent's base directory. BaseDir string // CharmDir is the directory to which the charm the uniter runs is deployed. CharmDir string // BundlesDir holds downloaded charms. BundlesDir string // DeployerDir holds metadata about charms that are installing or have // been installed. DeployerDir string // MetricsSpoolDir acts as temporary storage for metrics being sent from // the uniter to state. MetricsSpoolDir string }
StatePaths represents the set of paths that hold persistent local state for the uniter.
type Uniter ¶
type Uniter struct { Probe Probe // contains filtered or unexported fields }
Uniter implements the capabilities of the unit agent. It is not intended to implement the actual *behaviour* of the unit agent; that responsibility is delegated to Mode values, which are expected to react to events and direct the uniter's responses to them.
func NewUniter ¶
func NewUniter(uniterParams *UniterParams) (*Uniter, error)
NewUniter creates a new Uniter which will install, run, and upgrade a charm on behalf of the unit with the given unitTag, by executing hooks and operations provoked by changes in st.
func (*Uniter) RunCommands ¶
func (u *Uniter) RunCommands(args RunCommandsArgs) (results *exec.ExecResponse, err error)
RunCommands executes the supplied commands in a hook context.
type UniterExecutionObserver ¶
type UniterExecutionObserver interface { HookCompleted(hookName string) HookFailed(hookName string) }
A UniterExecutionObserver gets the appropriate methods called when a hook is executed and either succeeds or fails. Missing hooks don't get reported in this way.
type UniterParams ¶
type UniterParams struct { UniterFacade *uniter.State UnitTag names.UnitTag ModelType model.ModelType LeadershipTrackerFunc func(names.UnitTag) leadership.TrackerWorker DataDir string Downloader charm.Downloader MachineLock machinelock.Lock CharmDirGuard fortress.Guard UpdateStatusSignal remotestate.UpdateStatusTimerFunc HookRetryStrategy params.RetryStrategy NewOperationExecutor NewOperationExecutorFunc NewProcessRunner runner.NewRunnerFunc NewDeployer charm.NewDeployerFunc NewRemoteRunnerExecutor NewRunnerExecutorFunc RemoteInitFunc RemoteInitFunc RunListener *RunListener TranslateResolverErr func(error) error Clock clock.Clock ApplicationChannel watcher.NotifyChannel ContainerRunningStatusChannel watcher.NotifyChannel ContainerRunningStatusFunc remotestate.ContainerRunningStatusFunc IsRemoteUnit bool SocketConfig *SocketConfig // TODO (mattyw, wallyworld, fwereade) Having the observer here make this approach a bit more legitimate, but it isn't. // the observer is only a stop gap to be used in tests. A better approach would be to have the uniter tests start hooks // that write to files, and have the tests watch the output to know that hooks have finished. Observer UniterExecutionObserver RebootQuerier RebootQuerier Logger Logger Embedded bool EnforcedCharmModifiedVersion int ContainerNames []string NewPebbleClient NewPebbleClientFunc }
UniterParams hold all the necessary parameters for a new Uniter.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package hook provides types that define the hooks known to the Uniter
|
Package hook provides types that define the hooks known to the Uniter |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
relation implements persistent local storage of a unit's relation state, and translation of relation changes into hooks that need to be run.
|
relation implements persistent local storage of a unit's relation state, and translation of relation changes into hooks that need to be run. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
context
Package context contains the ContextFactory and Context definitions.
|
Package context contains the ContextFactory and Context definitions. |
context/mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
jujuc
The worker/uniter/runner/jujuc package implements the server side of the jujuc proxy tool, which forwards command invocations to the unit agent process so that they can be executed against specific state.
|
The worker/uniter/runner/jujuc package implements the server side of the jujuc proxy tool, which forwards command invocations to the unit agent process so that they can be executed against specific state. |
jujuc/mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
Package storage contains the storage subsystem for the uniter, responding to changes in storage attachments (lifecycle, volume/filesystem details) by queuing hooks and managing the storage attachments' lifecycle.
|
Package storage contains the storage subsystem for the uniter, responding to changes in storage attachments (lifecycle, volume/filesystem details) by queuing hooks and managing the storage attachments' lifecycle. |