import "github.com/juju/juju/worker/uniter"
agent.go manifold.go op_callbacks.go paths.go resolver.go runlistener.go timer.go uniter.go
const JujuRunEndpoint = "JujuRunServer.RunCommands"
var ( // ErrCAASUnitDead is the error returned from terminate or init // if the unit is Dead. ErrCAASUnitDead = errors.New("unit dead") )
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 NewRunListenerWrapper(rl *RunListener) 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(cfg ResolverConfig) resolver.Resolver
NewUniterResolver returns a new resolver.Resolver for the uniter.
func NewUpdateStatusTimer() remotestate.UpdateStatusTimerFunc
NewUpdateStatusTimer returns a func returning timed signal suitable for update-status hook.
func StartUniter(runner *worker.Runner, params *UniterParams) error
StartUniter creates a new Uniter and starts it using the specified runner.
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.
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(cfg ChannelCommandRunnerConfig) (*ChannelCommandRunner, error)
NewChannelCommandRunner returns a new ChannelCommandRunner with the given configuration.
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 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 (cfg ChannelCommandRunnerConfig) Validate() error
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 JujuRunServer struct {
// contains filtered or unexported fields
}
The JujuRunServer is the entity that has the methods that are called over the rpc connection.
func (r *JujuRunServer) RunCommands(args RunCommandsArgs, result *exec.ExecResponse) error
RunCommands delegates the actual running to the runner and populates the response structure.
type ManifoldConfig struct { AgentName string APICallerName string MachineLock machinelock.Lock Clock clock.Clock LeadershipTrackerName string CharmDirName string HookRetryStrategyName string TranslateResolverErr func(error) error }
ManifoldConfig defines the names of the manifolds on which a Manifold will depend.
type NewOperationExecutorFunc func(string, operation.State, func(string) (func(), error)) (operation.Executor, error)
type NewRunnerExecutorFunc func(ProviderIDGetter, Paths) runner.ExecFunc
NewRunnerExecutorFunc defines the type of the NewRunnerExecutor.
type NopResolver struct{}
NopResolver is a resolver that does nothing.
func (NopResolver) NextOp(resolver.LocalState, remotestate.Snapshot, operation.Factory) (operation.Operation, error)
The NopResolver's NextOp operation should always return the no operation error.
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.
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(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.
ComponentDir returns the filesystem path to the directory containing all data files for a component.
GetBaseDir exists to satisfy the context.Paths interface.
GetCharmDir exists to satisfy the context.Paths interface.
GetJujucClientSocket exists to satisfy the context.Paths interface.
GetJujucServerSocket exists to satisfy the context.Paths interface.
GetMetricsSpoolDir exists to satisfy the runner.Paths interface.
GetToolsDir exists to satisfy the context.Paths interface.
ProviderIDGetter defines the API to get provider ID.
type ResolverConfig struct { ModelType model.ModelType ClearResolved func() error ReportHookError func(hook.Info) error ShouldRetryHooks bool StartRetryHookTimer func() StopRetryHookTimer func() UpgradeSeries resolver.Resolver Leadership resolver.Resolver Actions resolver.Resolver Relations resolver.Resolver Storage resolver.Resolver Commands resolver.Resolver }
ResolverConfig defines configuration for the uniter resolver.
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 }
RunCommandsArgs stores the arguments for a RunCommands call.
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(socket sockets.Socket) (*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 (r *RunListener) Close() error
Close immediately stops accepting connections, and blocks until all existing connections have been closed.
func (r *RunListener) RegisterRunner(unitName string, runner CommandRunner)
RegisterRunner registers a command runner for a given unit.
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 (r *RunListener) RunCommands(args RunCommandsArgs) (results *exec.ExecResponse, err error)
RunCommands executes the supplied commands in a hook context.
func (r *RunListener) UnregisterRunner(unitName string)
UnregisterRunner unregisters a command runner for a given unit.
type RuntimePaths struct { // JujuRunSocket listens for juju-run invocations, and is always // active. LocalJujuRunSocket SocketPair // RemoteJujuRunSocket listens for remote juju-run invocations. RemoteJujuRunSocket 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.
SocketConfig specifies information for remote sockets.
SocketPair is a server+client pair of socket descriptors.
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 // OperationsFile holds information about what the uniter is doing // and/or has done. OperationsFile string // RelationsDir holds relation-specific information about what the // uniter is doing and/or has done. RelationsDir string // BundlesDir holds downloaded charms. BundlesDir string // DeployerDir holds metadata about charms that are installing or have // been installed. DeployerDir string // StorageDir holds storage-specific information about what the // uniter is doing and/or has done. StorageDir 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 struct {
// 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(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 (u *Uniter) RunCommands(args RunCommandsArgs) (results *exec.ExecResponse, err error)
RunCommands executes the supplied commands in a hook context.
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 struct { UniterFacade *uniter.State UnitTag names.UnitTag ModelType model.ModelType LeadershipTracker leadership.TrackerWorker DataDir string Downloader charm.Downloader MachineLock machinelock.Lock CharmDirGuard fortress.Guard UpdateStatusSignal remotestate.UpdateStatusTimerFunc HookRetryStrategy params.RetryStrategy NewOperationExecutor NewOperationExecutorFunc NewRemoteRunnerExecutor NewRunnerExecutorFunc RunListener *RunListener TranslateResolverErr func(error) error Clock clock.Clock ApplicationChannel watcher.NotifyChannel RunningStatusChannel watcher.NotifyChannel RunningStatusFunc remotestate.RunningStatusFunc 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 }
UniterParams hold all the necessary parameters for a new Uniter.
Path | Synopsis |
---|---|
actions | |
charm | |
hook | Package hook provides types that define the hooks known to the Uniter |
leadership | |
operation | |
operation/mocks | Package mocks is a generated GoMock package. |
relation | relation implements persistent local storage of a unit's relation state, and translation of relation changes into hooks that need to be run. |
remotestate | |
resolver | |
runcommands | |
runner | |
runner/context | Package context contains the ContextFactory and Context definitions. |
runner/debug | |
runner/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. |
runner/jujuc/jujuctesting | |
runner/testing | |
storage | 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. |
upgradeseries |
Package uniter imports 55 packages (graph) and is imported by 139 packages. Updated 2019-12-13. Refresh now. Tools for package owners.