uniter

package
v0.0.0-...-be26699 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2015 License: AGPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const JujuRunEndpoint = "JujuRunServer.RunCommands"

Variables

This section is empty.

Functions

func AddStoppedFieldToUniterState

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

func NewMetricsTimerChooser

func NewMetricsTimerChooser() *timerChooser

NewMetricsTimerChooser returns a timerChooser for collect-metrics.

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 Mode

type Mode func(u *Uniter) (Mode, error)

Mode defines the signature of the functions that implement the possible states of a running Uniter.

func ModeAbide

func ModeAbide(u *Uniter) (next Mode, err error)

ModeAbide is the Uniter's usual steady state. It watches for and responds to: * service configuration changes * charm upgrade requests * relation changes * unit death * acquisition or loss of service leadership

func ModeConflicted

func ModeConflicted(curl *charm.URL) Mode

ModeConflicted is responsible for watching and responding to: * user resolution of charm upgrade conflicts * forced charm upgrade requests

func ModeContinue

func ModeContinue(u *Uniter) (next Mode, err error)

ModeContinue determines what action to take based on persistent uniter state.

func ModeHookError

func ModeHookError(u *Uniter) (next Mode, err error)

ModeHookError is responsible for watching and responding to: * user resolution of hook errors * forced charm upgrade requests * loss of service leadership

func ModeInstalling

func ModeInstalling(curl *charm.URL) (next Mode, err error)

ModeInstalling is responsible for the initial charm deployment. If an install operation were to set an appropriate status, it shouldn't be necessary; but see ModeUpgrading for discussion relevant to both.

func ModeTerminating

func ModeTerminating(u *Uniter) (next Mode, err error)

ModeTerminating marks the unit dead and returns ErrTerminateAgent.

func ModeUpgrading

func ModeUpgrading(curl *charm.URL) Mode

ModeUpgrading is responsible for upgrading the charm. It shouldn't really need to be a mode at all -- it's just running a single operation -- but it's not safe to call it inside arbitrary other modes, because failing to pass through ModeContinue on the way out could cause a queued hook to be accidentally skipped.

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 Relationer

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

Relationer manages a unit's presence in a relation.

func NewRelationer

func NewRelationer(ru *apiuniter.RelationUnit, dir *relation.StateDir, hooks chan<- hook.Info) *Relationer

NewRelationer creates a new Relationer. The unit will not join the relation until explicitly requested.

func (*Relationer) CommitHook

func (r *Relationer) CommitHook(hi hook.Info) error

CommitHook persists the fact of the supplied hook's completion.

func (*Relationer) ContextInfo

func (r *Relationer) ContextInfo() *runner.RelationInfo

ContextInfo returns a represention of r's current state.

func (*Relationer) IsImplicit

func (r *Relationer) IsImplicit() bool

IsImplicit returns whether the local relation endpoint is implicit. Implicit relations do not run hooks.

func (*Relationer) Join

func (r *Relationer) Join() error

Join initializes local state and causes the unit to enter its relation scope, allowing its counterpart units to detect its presence and settings changes. Local state directory is not created until needed.

func (*Relationer) PrepareHook

func (r *Relationer) PrepareHook(hi hook.Info) (hookName string, err error)

PrepareHook checks that the relation is in a state such that it makes sense to execute the supplied hook, and ensures that the relation context contains the latest relation state as communicated in the hook.Info. It returns the name of the hook that must be run.

func (*Relationer) SetDying

func (r *Relationer) SetDying() error

SetDying informs the relationer that the unit is departing the relation, and that the only hooks it should send henceforth are -departed hooks, until the relation is empty, followed by a -broken hook.

func (*Relationer) StartHooks

func (r *Relationer) StartHooks() error

StartHooks starts watching the relation, and sending hook.Info events on the hooks channel. It will panic if called when already responding to relation changes.

func (*Relationer) StopHooks

func (r *Relationer) StopHooks() error

StopHooks ensures that the relationer is not watching the relation, or sending hook.Info events on the hooks channel.

type Relations

type Relations interface {

	// Name returns the name of the relation with the supplied id, or an error
	// if the relation is unknown.
	Name(id int) (string, error)

	// Hooks returns the channel on which relation hook execution requests
	// are sent.
	Hooks() <-chan hook.Info

	// StartHooks starts sending hook execution requests on the Hooks channel.
	StartHooks()

	// StopHooks stops sending hook execution requests on the Hooks channel.
	StopHooks() error

	// PrepareHook returns the name of the supplied relation hook, or an error
	// if the hook is unknown or invalid given current state.
	PrepareHook(hookInfo hook.Info) (string, error)

	// CommitHook persists the state change encoded in the supplied relation
	// hook, or returns an error if the hook is unknown or invalid given
	// current relation state.
	CommitHook(hookInfo hook.Info) error

	// GetInfo returns information about current relation state.
	GetInfo() map[int]*runner.RelationInfo

	// Update checks for and responds to changes in the life states of the
	// relations with the supplied ids. If any id corresponds to an alive
	// relation that is not already recorded, the unit will enter scope for
	// that relation and start its hook queue.
	Update(ids []int) error

	// SetDying notifies all known relations that the only hooks to be requested
	// should be those necessary to cleanly exit the relation.
	SetDying() error
}

Relations exists to encapsulate relation state and operations behind an interface for the benefit of future refactoring.

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 seting 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()

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 TimedSignal

type TimedSignal func(now, lastSignal time.Time, interval time.Duration) <-chan time.Time

Signal is the signature of a function used to generate a hook signal.

func NewUpdateStatusTimer

func NewUpdateStatusTimer() TimedSignal

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

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 {
	St                  *uniter.State
	UnitTag             names.UnitTag
	LeadershipManager   coreleadership.LeadershipManager
	DataDir             string
	HookLock            *fslock.Lock
	MetricsTimerChooser *timerChooser
	UpdateStatusSignal  TimedSignal
}

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