uniter

package
v0.0.0-...-4bd6544 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2016 License: AGPL-3.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const JujuRunEndpoint = "JujuRunServer.RunCommands"

Variables

This section is empty.

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 NewUniterResolver

func NewUniterResolver(cfg ResolverConfig) resolver.Resolver

NewUniterResolver returns a new resolver.Resolver for the uniter.

func NewUpdateStatusTimer

func NewUpdateStatusTimer() func() <-chan time.Time

NewUpdateStatusTimer returns a timed signal suitable for update-status hook.

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 JujuRunServer

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 (*JujuRunServer) RunCommands

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

type ManifoldConfig struct {
	AgentName             string
	APICallerName         string
	MachineLockName       string
	Clock                 clock.Clock
	LeadershipTrackerName string
	CharmDirName          string
	HookRetryStrategyName string
}

ManifoldConfig defines the names of the manifolds on which a Manifold will depend.

type NewExecutorFunc

type NewExecutorFunc func(string, func() (*corecharm.URL, error), func() (mutex.Releaser, error)) (operation.Executor, error)

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) Paths

NewPaths returns the set of filesystem paths that the supplied unit should use, given the supplied root juju data directory path.

func NewWorkerPaths

func NewWorkerPaths(dataDir string, unitTag names.UnitTag, worker string) 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.

func (Paths) ComponentDir

func (paths Paths) ComponentDir(name string) string

ComponentDir returns the filesystem path to the directory containing all data files for a component.

func (Paths) GetCharmDir

func (paths Paths) GetCharmDir() string

GetCharmDir exists to satisfy the context.Paths interface.

func (Paths) GetJujucSocket

func (paths Paths) GetJujucSocket() string

GetJujucSocket exists to satisfy the context.Paths interface.

func (Paths) GetMetricsSpoolDir

func (paths Paths) GetMetricsSpoolDir() string

GetMetricsSpoolDir exists to satisfy the runner.Paths interface.

func (Paths) GetToolsDir

func (paths Paths) GetToolsDir() string

GetToolsDir exists to satisfy the context.Paths interface.

type ResolverConfig

type ResolverConfig struct {
	ClearResolved       func() error
	ReportHookError     func(hook.Info) error
	ShouldRetryHooks    bool
	StartRetryHookTimer func()
	StopRetryHookTimer  func()
	Leadership          resolver.Resolver
	Actions             resolver.Resolver
	Relations           resolver.Resolver
	Storage             resolver.Resolver
	Commands            resolver.Resolver
}

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
	// ForceRemoteUnit skips relation membership and existence validation.
	ForceRemoteUnit bool
}

RunCommandsArgs stores the arguments for a RunCommands call.

type RunListener

type RunListener struct {
	RunListenerConfig
	// 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(cfg RunListenerConfig) (*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 (s *RunListener) Close() error

Close immediately stops accepting connections, and blocks until all existing connections have been closed.

func (*RunListener) Run

func (s *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.

type RunListenerConfig

type RunListenerConfig struct {
	// SocketPath is the path of the socket to listen on for run commands.
	SocketPath string

	// CommandRunner is the CommandRunner that will run commands.
	CommandRunner CommandRunner
}

RunListenerConfig contains the configuration for a RunListener.

func (*RunListenerConfig) Validate

func (cfg *RunListenerConfig) Validate() error

type RuntimePaths

type RuntimePaths struct {

	// JujuRunSocket listens for juju-run invocations, and is always
	// active.
	JujuRunSocket string

	// JujucServerSocket listens for jujuc invocations, and is only
	// active when supporting a jujuc execution context.
	JujucServerSocket string
}

RuntimePaths represents the set of paths that are relevant at runtime.

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

	// 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

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

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) Kill

func (u *Uniter) Kill()

func (*Uniter) RunCommands

func (u *Uniter) RunCommands(args RunCommandsArgs) (results *exec.ExecResponse, err error)

RunCommands executes the supplied commands in a hook context.

func (*Uniter) Wait

func (u *Uniter) Wait() error

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
	LeadershipTracker    leadership.Tracker
	DataDir              string
	Downloader           charm.Downloader
	MachineLockName      string
	CharmDirGuard        fortress.Guard
	UpdateStatusSignal   func() <-chan time.Time
	HookRetryStrategy    params.RetryStrategy
	NewOperationExecutor NewExecutorFunc
	Clock                clock.Clock
	// 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.

Directories

Path Synopsis
hook provides types that define the hooks known to the Uniter
hook provides types that define the hooks known to the Uniter
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.
context
Package context contains the ContextFactory and Context definitions.
Package context contains the ContextFactory and Context definitions.
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.
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.

Jump to

Keyboard shortcuts

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