Documentation ¶
Overview ¶
Package instancemutater defines workers that compares the list of lxd profiles applied to a machine with the list of expected profiles based on the application versions which should be running on the machine. In particular, it creates two workers from the same code with different configurations; the ContainerWorker, and the EnvironWorker.
The ContainerWorker runs on a machine and watches for containers to be created on it.
// ┌───────────────────────────────┐ // │ MACHINE │ // │ │ // │ │ // │ ┌──────────────────────┐ │ // │ │ │ │ // │ │ CONTAINER │ │ ┌────┼───► │ │ │ │ │ │ │ │ │ │ ┌────────────────┐ │ │ │ │ │ │ UNIT │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ┌────────────┐ │ │ │ │ │ │ │ │ CHARM │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─────┬──────┘ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └───────┼────────┘ │ │ │ │ │ │ │ │ │ │ └──────────┼───────────┘ │ │ │ │ │ │ └──────────────┼────────────────┘ │ │ └───────────────────┘
LXD PROFILE
The EnvironWorker watches for machines in the model to be created.
// ┌───────────────────────────────┐ // │ MACHINE │ // │ │ ┌────► │ │ │ ┌──────────────────────┐ │ │ │ │ │ │ │ │ │ CONTAINER │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ┌────────────────┐ │ │ │ │ │ │ UNIT │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ┌────────────┐ │ │ │ │ │ │ │ │ CHARM │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └─────┬──────┘ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └───────┼────────┘ │ │ │ │ │ │ │ │ │ │ └──────────┼───────────┘ │ │ │ │ │ │ └──────────────┼────────────────┘ │ │ └───────────────────┘ LXD PROFILE
To understand this better with a similar mechanism, take a look at the provisioner worker as well.
Index ¶
- func BrokerAPIManifold(config BrokerAPIConfig, start BrokerAPIStartFunc) dependency.Manifold
- func EnvironAPIManifold(config EnvironAPIConfig, start EnvironAPIStartFunc) dependency.Manifold
- func MachineManifold(config MachineManifoldConfig) dependency.Manifold
- func ModelManifold(config ModelManifoldConfig) dependency.Manifold
- func NewContainerWorker(config Config) (worker.Worker, error)
- func NewEnvironWorker(config Config) (worker.Worker, error)
- type BrokerAPIConfig
- type BrokerAPIStartFunc
- type Config
- type EnvironAPIConfig
- type EnvironAPIStartFunc
- type InstanceMutaterAPI
- type Logger
- type MachineContext
- type MachineManifoldConfig
- type ModelManifoldConfig
- type MutaterContext
- type MutaterMachine
- type RequiredLXDProfilesFunc
- type RequiredMutaterContextFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BrokerAPIManifold ¶
func BrokerAPIManifold(config BrokerAPIConfig, start BrokerAPIStartFunc) dependency.Manifold
BrokerAPIManifold returns a dependency.Manifold that calls the supplied start func with the API and envrion resources defined in the config (once those resources are present).
func EnvironAPIManifold ¶
func EnvironAPIManifold(config EnvironAPIConfig, start EnvironAPIStartFunc) dependency.Manifold
EnvironAPIManifold returns a dependency.Manifold that calls the supplied start func with the API and envrion resources defined in the config (once those resources are present).
func MachineManifold ¶
func MachineManifold(config MachineManifoldConfig) dependency.Manifold
MachineManifold returns a Manifold that encapsulates the instancemutater worker.
func ModelManifold ¶
func ModelManifold(config ModelManifoldConfig) dependency.Manifold
ModelManifold returns a Manifold that encapsulates the instancemutater worker.
func NewContainerWorker ¶
NewContainerWorker returns a worker that keeps track of the containers in the state for this machine agent and polls their instance for addition or removal changes.
func NewEnvironWorker ¶
NewEnvironWorker returns a worker that keeps track of the machines in the state and polls their instance for addition or removal changes.
Types ¶
type BrokerAPIConfig ¶
BrokerAPIConfig represents a typed manifold starter func, that handles getting resources from the configuration.
type BrokerAPIStartFunc ¶
type BrokerAPIStartFunc func(environs.InstanceBroker, base.APICaller, agent.Agent) (worker.Worker, error)
BrokerAPIStartFunc encapsulates creation of a worker based on the environ and APICaller.
type Config ¶
type Config struct { Facade InstanceMutaterAPI // Logger is the Logger for this worker. Logger Logger Broker environs.LXDProfiler AgentConfig agent.Config // Tag is the current MutaterMachine tag Tag names.Tag // GetMachineWatcher allows the worker to watch different "machines" // depending on whether this work is running with an environ broker // or a container broker. GetMachineWatcher func() (watcher.StringsWatcher, error) // GetRequiredLXDProfiles provides a slice of strings representing the // lxd profiles to be included on every LXD machine used given the // current model name. GetRequiredLXDProfiles RequiredLXDProfilesFunc // GetRequiredContext provides a way to override the given context // Note: the following is required for testing purposes when we have an // error case and we want to know when it's valid to kill/clean the worker. GetRequiredContext RequiredMutaterContextFunc }
Config represents the configuration required to run a new instance machineApi worker.
type EnvironAPIConfig ¶
EnvironAPIConfig represents a typed manifold starter func, that handles getting resources from the configuration.
type EnvironAPIStartFunc ¶
EnvironAPIStartFunc encapsulates creation of a worker based on the environ and APICaller.
type InstanceMutaterAPI ¶
type InstanceMutaterAPI interface { WatchModelMachines() (watcher.StringsWatcher, error) Machine(tag names.MachineTag) (instancemutater.MutaterMachine, error) }
func NewClient ¶
func NewClient(apiCaller base.APICaller) InstanceMutaterAPI
type Logger ¶
type Logger interface { Warningf(message string, args ...interface{}) Infof(message string, args ...interface{}) Debugf(message string, args ...interface{}) Errorf(message string, args ...interface{}) Tracef(message string, args ...interface{}) }
Logger represents the logging methods called.
type MachineContext ¶
type MachineContext interface {
// contains filtered or unexported methods
}
type MachineManifoldConfig ¶
type MachineManifoldConfig struct { APICallerName string BrokerName string AgentName string Logger Logger NewWorker func(Config) (worker.Worker, error) NewClient func(base.APICaller) InstanceMutaterAPI }
MachineManifoldConfig describes the resources used by the instancemuter worker.
func (MachineManifoldConfig) Validate ¶
func (config MachineManifoldConfig) Validate() error
Validate validates the manifold configuration.
type ModelManifoldConfig ¶
type ModelManifoldConfig struct { APICallerName string EnvironName string AgentName string Logger Logger NewWorker func(Config) (worker.Worker, error) NewClient func(base.APICaller) InstanceMutaterAPI }
ModelManifoldConfig describes the resources used by the instancemuter worker.
func (ModelManifoldConfig) Validate ¶
func (config ModelManifoldConfig) Validate() error
Validate validates the manifold configuration.
type MutaterContext ¶
type MutaterContext interface { MachineContext // contains filtered or unexported methods }
type MutaterMachine ¶
type MutaterMachine struct {
// contains filtered or unexported fields
}
type RequiredLXDProfilesFunc ¶
type RequiredMutaterContextFunc ¶
type RequiredMutaterContextFunc func(MutaterContext) MutaterContext