uniter

package
v0.0.0-...-a002913 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2015 License: AGPL-3.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const JujuRunEndpoint = "JujuRunServer.RunCommands"

Variables

This section is empty.

Functions

func AddInstalledToUniterState

func AddInstalledToUniterState(tag names.UnitTag, dataDir string) error

AddInstalledToUniterState sets the Installed boolean in state to true if the charm has been installed. The only occasion where this is not true is if we are currently installing.

func AddStoppedFieldToUniterState

func AddStoppedFieldToUniterState(tag names.UnitTag, dataDir string) error

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 NewUpdateStatusTimer

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

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

Types

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
	LeadershipTrackerName string
	CharmDirName          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(string) (func() error, 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 (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 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 {
	// 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(runner CommandRunner, socketPath string) (*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.

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 {

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

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

func (u *Uniter) Dead() <-chan struct{}

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

func (u *Uniter) Stop() error

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
	MachineLock          *fslock.Lock
	CharmDirLocker       charmdir.Locker
	UpdateStatusSignal   func() <-chan time.Time
	NewOperationExecutor NewExecutorFunc
	// 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