juju: github.com/juju/juju/worker/upgradedatabase Index | Files | Directories

package upgradedatabase

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

Index

Package Files

manifold.go shim.go worker.go

func Manifold Uses

func Manifold(cfg ManifoldConfig) dependency.Manifold

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

func NewLock Uses

func NewLock(agentConfig agent.Config) gate.Lock

NewLock creates a gate.Lock to be used to synchronise workers that need to start after database upgrades have completed. The returned Lock should be passed to NewWorker. If the agent has already upgraded to the current version, then the lock will be returned in the released state.

func NewWorker Uses

func NewWorker(cfg Config) (worker.Worker, error)

NewWorker validates the input configuration, then uses it to create, start and return an upgradeDB worker.

type Clock Uses

type Clock interface {
    // After waits for the duration to elapse and then sends the
    // current time on the returned channel.
    After(time.Duration) <-chan time.Time
}

Clock provides an interface for dealing with clocks.

type Config Uses

type Config struct {
    // UpgradeComplete is a lock used to synchronise workers that must start
    // after database upgrades are verified as completed.
    UpgradeComplete gate.Lock

    // Tag is the current machine tag.
    Tag names.Tag

    // agent is the running machine agent.
    Agent agent.Agent

    // Logger is the logger for this worker.
    Logger Logger

    // Open state is a function pointer for returning a state pool indirection.
    OpenState func() (Pool, error)

    // PerformUpgrade is a function pointer for executing the DB upgrade steps.
    // Context retrieval is lazy because because it requires a real
    // state.StatePool that we cast our Pool indirection back to.
    // We need the concrete type, because we are unable to indirect all the
    // state methods that upgrade steps might require.
    // This is OK for in-theatre operation, but is not suitable for testing.
    PerformUpgrade func(version.Number, []upgrades.Target, func() upgrades.Context) error

    // RetryStrategy is the strategy to use for re-attempting failed upgrades.
    RetryStrategy utils.AttemptStrategy

    // Clock is used to enforce time-out logic for controllers waiting for the
    // master MongoDB upgrades to execute.
    Clock Clock
}

Config is the configuration needed to construct an upgradeDB worker.

func (Config) Validate Uses

func (cfg Config) Validate() error

Validate returns an error if the worker config is not valid.

type Logger Uses

type Logger interface {
    Debugf(message string, args ...interface{})
    Infof(message string, args ...interface{})
    Errorf(message string, args ...interface{})
}

Logger represents the methods required to emit log messages.

type ManifoldConfig Uses

type ManifoldConfig struct {
    AgentName         string
    UpgradeDBGateName string
    Logger            Logger
    OpenState         func() (*state.StatePool, error)
    Clock             Clock
}

ManifoldConfig defines the configuration on which this manifold depends.

func (ManifoldConfig) Validate Uses

func (cfg ManifoldConfig) Validate() error

Validate returns an error if the manifold config is not valid.

type Pool Uses

type Pool interface {
    // IsPrimary returns true if the Mongo primary is
    // running on the machine with the input ID.
    IsPrimary(string) (bool, error)

    // SetStatus updates the status of the machine with the input ID.
    SetStatus(string, status.Status, string) error

    // EnsureUpgradeInfo ensures that a document exists in the "upgradeInfo"
    // collection for coordinating the current upgrade.
    EnsureUpgradeInfo(string, version.Number, version.Number) (UpgradeInfo, error)

    // Close closes the state pool.
    Close() error
}

State describes methods required by the upgradeDB worker that use access to a state pool.

type UpgradeInfo Uses

type UpgradeInfo interface {
    // Status returns the current status of the upgrade.
    Status() state.UpgradeStatus

    // SetStatus sets the current status of the upgrade.
    SetStatus(status state.UpgradeStatus) error

    // Watch returns a watcher that notifies of changes to the UpgradeInfo.
    Watch() state.NotifyWatcher

    // Refresh refreshes the UpgradeInfo from state.
    Refresh() error
}

UpgradeInfo describes methods for working with the state representation of an upgrade-in-progress.

Directories

PathSynopsis
mocksPackage mocks is a generated GoMock package.

Package upgradedatabase imports 16 packages (graph) and is imported by 3 packages. Updated 2019-11-14. Refresh now. Tools for package owners.