upgradedatabase

package
v0.0.0-...-9ec3720 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Manifold

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

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

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

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

Types

type Clock

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

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

func (cfg Config) Validate() error

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

type Logger

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

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

func (cfg ManifoldConfig) Validate() error

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

type Pool

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

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

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL