upgradedatabase

package
v0.0.0-...-c3d9892 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: AGPL-3.0 Imports: 22 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 NewUpgradeDatabaseWorker

func NewUpgradeDatabaseWorker(config Config) (worker.Worker, error)

NewUpgradeDatabaseWorker returns a new Worker.

Types

type Config

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

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

	// ModelService is the model manager service used to identify
	// the model uuids required to upgrade.
	ModelService ModelService

	// UpgradeService is the upgrade service used to drive the upgrade.
	UpgradeService UpgradeService

	// DBGetter is the database getter used to get the database for each model.
	DBGetter coredatabase.DBGetter

	// Tag holds the controller tag information.
	Tag names.Tag

	// Versions of the source and destination.
	FromVersion version.Number
	ToVersion   version.Number

	Logger logger.Logger
	Clock  clock.Clock
}

Config holds the configuration for the worker.

func (Config) Validate

func (c Config) Validate() error

Validate validates the worker configuration.

type ManifoldConfig

type ManifoldConfig struct {
	AgentName          string
	UpgradeDBGateName  string
	DomainServicesName string
	DBAccessorName     string
	Logger             logger.Logger
	Clock              clock.Clock
	NewWorker          func(Config) (worker.Worker, error)
}

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 ModelService

type ModelService interface {
	// ListModelIDs returns a list of all model UUIDs.
	// This only includes active models from the perspective of dqlite. These
	// are not the same as alive models.
	ListModelIDs(context.Context) ([]coremodel.UUID, error)
}

ModelService is the interface for the model service.

type UpgradeService

type UpgradeService interface {
	// CreateUpgrade creates an upgrade to and from specified versions
	// If an upgrade is already running/pending, return an AlreadyExists err
	CreateUpgrade(ctx context.Context, previousVersion, targetVersion version.Number) (domainupgrade.UUID, error)
	// SetControllerReady marks the supplied controllerID as being ready
	// to start its upgrade. All provisioned controllers need to be ready
	// before an upgrade can start
	SetControllerReady(ctx context.Context, upgradeUUID domainupgrade.UUID, controllerID string) error
	// StartUpgrade starts the current upgrade if it exists. If it is already
	// started it will return an AlreadyStarted error.
	StartUpgrade(ctx context.Context, upgradeUUID domainupgrade.UUID) error
	// SetDBUpgradeCompleted marks the upgrade as completed in the database
	SetDBUpgradeCompleted(ctx context.Context, upgradeUUID domainupgrade.UUID) error
	// SetDBUpgradeFailed marks the upgrade as failed in the database
	SetDBUpgradeFailed(ctx context.Context, upgradeUUID domainupgrade.UUID) error
	// ActiveUpgrade returns the uuid of the current active upgrade. If there
	// are no active upgrades, return an upgradeerrors.NotFound error.
	ActiveUpgrade(ctx context.Context) (domainupgrade.UUID, error)
	// UpgradeInfo returns the upgrade info for the supplied upgradeUUID. If
	// there are no active upgrades, return an upgradeerrors.NotFound error.
	UpgradeInfo(ctx context.Context, upgradeUUID domainupgrade.UUID) (upgrade.Info, error)
	// WatchForUpgradeReady creates a watcher which notifies when all controller
	// nodes have been registered, meaning the upgrade is ready to start.
	WatchForUpgradeReady(ctx context.Context, upgradeUUID domainupgrade.UUID) (watcher.NotifyWatcher, error)
	// WatchForUpgradeState creates a watcher which notifies when the upgrade
	// has reached the given state.
	WatchForUpgradeState(ctx context.Context, upgradeUUID domainupgrade.UUID, state upgrade.State) (watcher.NotifyWatcher, error)
}

UpgradeService is the interface for the upgrade service.

Jump to

Keyboard shortcuts

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