juju: github.com/juju/juju/worker/deployer Index | Files

package deployer

import "github.com/juju/juju/worker/deployer"


Package Files

deployer.go manifold.go nested.go unit_agent.go unit_manifolds.go

func Manifold Uses

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency manifold that runs a deployer worker, using the resource names defined in the supplied config.

func NewDeployer Uses

func NewDeployer(st API, logger Logger, ctx Context) (worker.Worker, error)

NewDeployer returns a Worker that deploys and recalls unit agents via ctx, taking a machine id to operate on.

func UnitManifolds Uses

func UnitManifolds(config UnitManifoldsConfig) dependency.Manifolds

UnitManifolds returns a set of co-configured manifolds covering the various responsibilities of nested unit agent.

Thou Shalt Not Use String Literals In This Function. Or Else.

type API Uses

type API interface {
    Machine(names.MachineTag) (Machine, error)
    Unit(names.UnitTag) (Unit, error)

API is used to define the methods that the deployer makes.

type Context Uses

type Context interface {

    // DeployUnit causes the agent for the specified unit to be started and run
    // continuously until further notice without further intervention. It will
    // return an error if the agent is already deployed.
    DeployUnit(unitName, initialPassword string) error

    // RecallUnit causes the agent for the specified unit to be stopped, and
    // the agent's data to be destroyed. It will return an error if the agent
    // was not deployed by the manager.
    RecallUnit(unitName string) error

    // DeployedUnits returns the names of all units deployed by the manager.
    DeployedUnits() ([]string, error)

    // AgentConfig returns the agent config for the machine agent that is
    // running the deployer.
    AgentConfig() agent.Config

    Report() map[string]interface{}

Context abstracts away the differences between different unit deployment strategies; where a Deployer is responsible for what to deploy, a Context is responsible for how to deploy.

func NewNestedContext Uses

func NewNestedContext(config ContextConfig) (Context, error)

NewNestedContext creates a new deployer context that is responsible for running the workers for units as individual dependency engines in a runner it owns.

type ContextConfig Uses

type ContextConfig struct {
    Agent            agent.Agent
    Clock            clock.Clock
    Hub              Hub
    Logger           Logger
    UnitEngineConfig func() dependency.EngineConfig
    SetupLogging     func(*loggo.Context, agent.Config)
    UnitManifolds    func(config UnitManifoldsConfig) dependency.Manifolds

ContextConfig contains all the information that the nested context needs to run.

func (*ContextConfig) Validate Uses

func (c *ContextConfig) Validate() error

Validate ensures all the required values are set.

type Deployer Uses

type Deployer struct {
    // contains filtered or unexported fields

Deployer is responsible for deploying and recalling unit agents, according to changes in a set of state units; and for the final removal of its agents' units from state when they are no longer needed.

func (*Deployer) Handle Uses

func (d *Deployer) Handle(_ <-chan struct{}, unitNames []string) error

Handle is called for new value in the StringsWatcher.

func (*Deployer) Report Uses

func (d *Deployer) Report() map[string]interface{}

Report is shown in the engine report.

func (*Deployer) SetUp Uses

func (d *Deployer) SetUp() (watcher.StringsWatcher, error)

SetUp is called by the NewStringsWorker to create the watcher that drives the worker.

func (*Deployer) TearDown Uses

func (d *Deployer) TearDown() error

TearDown stops the embedded context.

type Hub Uses

type Hub interface {
    Publish(topic string, data interface{}) <-chan struct{}
    Subscribe(topic string, handler func(string, interface{})) func()

Hub is a pubsub hub used for internal messaging.

type Logger Uses

type Logger interface {
    Errorf(string, ...interface{})
    Warningf(string, ...interface{})
    Infof(string, ...interface{})
    Debugf(string, ...interface{})
    Tracef(string, ...interface{})

Logger represents a logger used by the context.

type Machine Uses

type Machine interface {
    WatchUnits() (watcher.StringsWatcher, error)

Machine defines the methods that the deployer makes on a machine in the model.

type ManifoldConfig Uses

type ManifoldConfig struct {
    AgentName     string
    APICallerName string
    Clock         clock.Clock
    Hub           Hub
    Logger        Logger

    UnitEngineConfig func() dependency.EngineConfig
    SetupLogging     func(*loggo.Context, agent.Config)
    NewDeployContext func(ContextConfig) (Context, error)

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

type Unit Uses

type Unit interface {
    Life() life.Value
    Name() string
    Remove() error
    SetPassword(password string) error
    SetStatus(unitStatus status.Status, info string, data map[string]interface{}) error

Unit defines the methods that the deployer makes on a unit in the model.

type UnitAgent Uses

type UnitAgent struct {
    // contains filtered or unexported fields

UnitAgent wraps the agent config for this unit.

func NewUnitAgent Uses

func NewUnitAgent(config UnitAgentConfig) (*UnitAgent, error)

NewUnitAgent constructs an "agent" that is responsible for defining the workers for the unit and wraps access and updates to the agent.conf file for the unit. The method expects that there is an agent.conf file written in the <datadir>/agents/unit-<name> directory. It would be good to remove this need moving forwards and have unit agent logging overrides allowable in the machine agent config file.

func (*UnitAgent) ChangeConfig Uses

func (a *UnitAgent) ChangeConfig(change agent.ConfigMutator) error

ChangeConfig modifies this configuration using the given mutator.

func (*UnitAgent) CurrentConfig Uses

func (a *UnitAgent) CurrentConfig() agent.Config

CurrentConfig returns the agent config for this agent.

type UnitAgentConfig Uses

type UnitAgentConfig struct {
    Name             string
    DataDir          string
    Clock            clock.Clock
    Logger           Logger
    UnitEngineConfig func() dependency.EngineConfig
    UnitManifolds    func(UnitManifoldsConfig) dependency.Manifolds
    SetupLogging     func(*loggo.Context, agent.Config)

UnitAgentConfig is a params struct with the values necessary to construct a working unit agent.

func (*UnitAgentConfig) Validate Uses

func (u *UnitAgentConfig) Validate() error

Validate ensures all the required values are set.

type UnitManifoldsConfig Uses

type UnitManifoldsConfig struct {

    // LoggingContext holds the unit writers so that the loggers
    // for the unit get tagged with the right source.
    LoggingContext *loggo.Context

    // Agent contains the agent that will be wrapped and made available to
    // its dependencies via a dependency.Engine.
    Agent coreagent.Agent

    // LogSource will be read from by the logsender component.
    LogSource logsender.LogRecordCh

    // LeadershipGuarantee controls the behaviour of the leadership tracker.
    LeadershipGuarantee time.Duration

    // AgentConfigChanged is set whenever the unit agent's config
    // is updated.
    AgentConfigChanged *voyeur.Value

    // ValidateMigration is called by the migrationminion during the
    // migration process to check that the agent will be ok when
    // connected to the new target controller.
    ValidateMigration func(base.APICaller) error

    // UpdateLoggerConfig is a function that will save the specified
    // config value as the logging config in the agent.conf file.
    UpdateLoggerConfig func(string) error

    // MachineLock is a central source for acquiring the machine lock.
    // This is used by a number of workers to ensure serialisation of actions
    // across the machine.
    MachineLock machinelock.Lock

    // Clock supplies timekeeping services to various workers.
    Clock clock.Clock

UnitManifoldsConfig allows specialisation of the result of Manifolds.

Package deployer imports 56 packages (graph) and is imported by 70 packages. Updated 2020-08-09. Refresh now. Tools for package owners.