Documentation ¶
Overview ¶
Package overlord implements the overall control of a snappy system.
Index ¶
- type Overlord
- func (o *Overlord) AddManager(mgr StateManager)
- func (o *Overlord) AssertManager() *assertstate.AssertManager
- func (o *Overlord) CanStandby() bool
- func (o *Overlord) CommandManager() *cmdstate.CommandManager
- func (o *Overlord) DeviceManager() *devicestate.DeviceManager
- func (o *Overlord) HookManager() *hookstate.HookManager
- func (o *Overlord) InterfaceManager() *ifacestate.InterfaceManager
- func (o *Overlord) Loop()
- func (o *Overlord) RestartManager() *restart.RestartManager
- func (o *Overlord) ServiceManager() *servicestate.ServiceManager
- func (o *Overlord) Settle(timeout time.Duration) error
- func (o *Overlord) SettleObserveBeforeCleanups(timeout time.Duration, beforeCleanups func()) error
- func (o *Overlord) SnapManager() *snapstate.SnapManager
- func (o *Overlord) SnapshotManager() *snapshotstate.SnapshotManager
- func (o *Overlord) StartUp() error
- func (o *Overlord) StartupTimeout() (timeout time.Duration, reasoning string, err error)
- func (o *Overlord) State() *state.State
- func (o *Overlord) StateEngine() *StateEngine
- func (o *Overlord) Stop() error
- func (o *Overlord) TaskRunner() *state.TaskRunner
- type StateEngine
- type StateManager
- type StateStarterUp
- type StateStopper
- type StateWaiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Overlord ¶
type Overlord struct {
// contains filtered or unexported fields
}
Overlord is the central manager of a snappy system, keeping track of all available state managers and related helpers.
func Mock ¶
func Mock() *Overlord
Mock creates an Overlord without any managers and with a backend not using disk. Managers can be added with AddManager. For testing.
func MockWithState ¶
MockWithState creates an Overlord with the given state unless it is nil in which case it uses a state backend not using disk. Managers can be added with AddManager. For testing.
func New ¶
New creates a new Overlord with all its state managers. It can be provided with an optional restart.Handler.
func (*Overlord) AddManager ¶
func (o *Overlord) AddManager(mgr StateManager)
AddManager adds a manager to the overlord created with Mock. For testing.
func (*Overlord) AssertManager ¶
func (o *Overlord) AssertManager() *assertstate.AssertManager
AssertManager returns the assertion manager enforcing assertions under the overlord.
func (*Overlord) CanStandby ¶
func (*Overlord) CommandManager ¶
func (o *Overlord) CommandManager() *cmdstate.CommandManager
CommandManager returns the manager responsible for running odd jobs.
func (*Overlord) DeviceManager ¶
func (o *Overlord) DeviceManager() *devicestate.DeviceManager
DeviceManager returns the device manager responsible for the device identity and policies.
func (*Overlord) HookManager ¶
func (o *Overlord) HookManager() *hookstate.HookManager
HookManager returns the hook manager responsible for running hooks under the overlord.
func (*Overlord) InterfaceManager ¶
func (o *Overlord) InterfaceManager() *ifacestate.InterfaceManager
InterfaceManager returns the interface manager maintaining interface connections under the overlord.
func (*Overlord) Loop ¶
func (o *Overlord) Loop()
Loop runs a loop in a goroutine to ensure the current state regularly through StateEngine Ensure.
func (*Overlord) RestartManager ¶
func (o *Overlord) RestartManager() *restart.RestartManager
RestartManager returns the manager responsible for restart state.
func (*Overlord) ServiceManager ¶
func (o *Overlord) ServiceManager() *servicestate.ServiceManager
ServiceManager returns the manager responsible for services under the overlord.
func (*Overlord) Settle ¶
Settle runs first a state engine Ensure and then wait for activities to settle. That's done by waiting for all managers' activities to settle while making sure no immediate further Ensure is scheduled. It then waits similarly for all ready changes to reach the clean state. Chiefly for tests. Cannot be used in conjunction with Loop. If timeout is non-zero and settling takes longer than timeout, returns an error. Calls StartUp as well.
func (*Overlord) SettleObserveBeforeCleanups ¶
SettleObserveBeforeCleanups runs first a state engine Ensure and then wait for activities to settle. That's done by waiting for all managers' activities to settle while making sure no immediate further Ensure is scheduled. It then waits similarly for all ready changes to reach the clean state, but calls once the provided callback before doing that. Chiefly for tests. Cannot be used in conjunction with Loop. If timeout is non-zero and settling takes longer than timeout, returns an error. Calls StartUp as well.
func (*Overlord) SnapManager ¶
func (o *Overlord) SnapManager() *snapstate.SnapManager
SnapManager returns the snap manager responsible for snaps under the overlord.
func (*Overlord) SnapshotManager ¶
func (o *Overlord) SnapshotManager() *snapshotstate.SnapshotManager
SnapshotManager returns the manager responsible for snapshots.
func (*Overlord) StartUp ¶
StartUp proceeds to run any expensive Overlord or managers initialization. After this is done once it is a noop.
func (*Overlord) StartupTimeout ¶
StartupTimeout computes a usable timeout for the startup initializations by using a pessimistic estimate.
func (*Overlord) StateEngine ¶
func (o *Overlord) StateEngine() *StateEngine
StateEngine returns the stage engine used by overlord.
func (*Overlord) TaskRunner ¶
func (o *Overlord) TaskRunner() *state.TaskRunner
TaskRunner returns the shared task runner responsible for running tasks for all managers under the overlord.
type StateEngine ¶
type StateEngine struct {
// contains filtered or unexported fields
}
StateEngine controls the dispatching of state changes to state managers.
Most of the actual work performed by the state engine is in fact done by the individual managers registered. These managers must be able to cope with Ensure calls in any order, coordinating among themselves solely via the state.
func NewStateEngine ¶
func NewStateEngine(s *state.State) *StateEngine
NewStateEngine returns a new state engine.
func (*StateEngine) AddManager ¶
func (se *StateEngine) AddManager(m StateManager)
AddManager adds the provided manager to take part in state operations.
func (*StateEngine) Ensure ¶
func (se *StateEngine) Ensure() error
Ensure asks every manager to ensure that they are doing the necessary work to put the current desired system state in place by calling their respective Ensure methods.
Managers must evaluate the desired state completely when they receive that request, and report whether they found any critical issues. They must not perform long running activities during that operation, though. These should be performed in properly tracked changes and tasks.
func (*StateEngine) StartUp ¶
func (se *StateEngine) StartUp() error
StartUp asks all managers to perform any expensive initialization. It is a noop after the first invocation.
func (*StateEngine) State ¶
func (se *StateEngine) State() *state.State
State returns the current system state.
func (*StateEngine) Stop ¶
func (se *StateEngine) Stop()
Stop asks all managers to terminate activities running concurrently.
func (*StateEngine) Wait ¶
func (se *StateEngine) Wait()
Wait waits for all managers current activities.
type StateManager ¶
type StateManager interface { // Ensure forces a complete evaluation of the current state. // See StateEngine.Ensure for more details. Ensure() error }
StateManager is implemented by types responsible for observing the system and manipulating it to reflect the desired state.
type StateStarterUp ¶
type StateStarterUp interface { // StartUp asks manager to perform any expensive initialization. StartUp() error }
StateStarterUp is optionally implemented by StateManager that have expensive initialization to perform before the main Overlord loop.
type StateStopper ¶
type StateStopper interface { // Stop asks the manager to terminate all activities running // concurrently. It must not return before these activities // are finished. Stop() }
StateStopper is optionally implemented by StateManagers that have running activities that can be terminated.
type StateWaiter ¶
type StateWaiter interface { // Wait asks manager to wait for all running activities to // finish. Wait() }
StateWaiter is optionally implemented by StateManagers that have running activities that can be waited.
Directories ¶
Path | Synopsis |
---|---|
Package assertstate implements the manager and state aspects responsible for the enforcement of assertions in the system and manages the system-wide assertion database.
|
Package assertstate implements the manager and state aspects responsible for the enforcement of assertions in the system and manages the system-wide assertion database. |
Package cmdstate implements a overlord.StateManager that excutes arbitrary commands as tasks.
|
Package cmdstate implements a overlord.StateManager that excutes arbitrary commands as tasks. |
Package configstate implements the manager and state aspects responsible for the configuration of snaps.
|
Package configstate implements the manager and state aspects responsible for the configuration of snaps. |
Package devicestate implements the manager and state aspects responsible for the device identity and policies.
|
Package devicestate implements the manager and state aspects responsible for the device identity and policies. |
internal
Package internal (of devicestate) provides functions to access and set the device state for use only by devicestate, for convenience they are also exposed via devicestatetest for use in tests.
|
Package internal (of devicestate) provides functions to access and set the device state for use only by devicestate, for convenience they are also exposed via devicestatetest for use in tests. |
Package hookstate implements the manager and state aspects responsible for the running of hooks.
|
Package hookstate implements the manager and state aspects responsible for the running of hooks. |
ctlcmd
Package ctlcmd contains the various snapctl subcommands.
|
Package ctlcmd contains the various snapctl subcommands. |
Package ifacestate implements the manager and state aspects responsible for the maintenance of interfaces the system.
|
Package ifacestate implements the manager and state aspects responsible for the maintenance of interfaces the system. |
schema
Package schema holds structs for reading and writing interface-related state data.
|
Package schema holds structs for reading and writing interface-related state data. |
Package install implements installation logic details for UC20+ systems.
|
Package install implements installation logic details for UC20+ systems. |
Package restart implements requesting restarts from any part of the code that has access to state.
|
Package restart implements requesting restarts from any part of the code that has access to state. |
Package snapstate implements the manager and state aspects responsible for the installation and removal of snaps.
|
Package snapstate implements the manager and state aspects responsible for the installation and removal of snaps. |
backend
Package backend implements the low-level primitives to manage the snaps and their installation on disk.
|
Package backend implements the low-level primitives to manage the snaps and their installation on disk. |
policy
Package policy implements fine grained decision-making for snapstate
|
Package policy implements fine grained decision-making for snapstate |
sequence
Package sequence contains types representing a sequence of snap revisions (with components) that describe current and past states of the snap in the system.
|
Package sequence contains types representing a sequence of snap revisions (with components) that describe current and past states of the snap in the system. |
Package state implements the representation of system state.
|
Package state implements the representation of system state. |
Package storecontext supplies a pluggable implementation of store.DeviceAndAuthContext.
|
Package storecontext supplies a pluggable implementation of store.DeviceAndAuthContext. |