migrationmaster

package
v0.0.0-...-b9bb202 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInactive is returned when the migration is no longer active
	// (probably aborted). In this case the migrationmaster should be
	// restarted so that it can wait for the next migration attempt.
	ErrInactive = errors.New("migration is no longer active")

	// ErrMigrated is returned when the model has migrated to another
	// server. The migrationmaster should not be restarted again in
	// this case.
	ErrMigrated = errors.New("model has migrated")
)

Functions

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold packages a Worker for use in a dependency.Engine.

func NewWorker

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

NewWorker creates a new Worker from the config supplied.

Types

type CharmService

type CharmService interface {
	// GetCharmID returns a charm ID by name. It returns an error if the charm
	// can not be found by the name.
	// This can also be used as a cheap way to see if a charm exists without
	// needing to load the charm metadata.
	GetCharmID(context.Context, charm.GetCharmArgs) (corecharm.ID, error)

	// GetCharmArchive returns a ReadCloser stream for the charm archive for a given
	// charm id, along with the hash of the charm archive. The hash to verify the
	// integrity of the charm archive.
	GetCharmArchive(context.Context, corecharm.ID) (io.ReadCloser, string, error)
}

type Config

type Config struct {
	ModelUUID       string
	Facade          Facade
	CharmService    CharmService
	Guard           fortress.Guard
	APIOpen         func(context.Context, *api.Info, api.DialOpts) (api.Connection, error)
	UploadBinaries  func(context.Context, migration.UploadBinariesConfig, logger.Logger) error
	ToolsDownloader migration.ToolsDownloader
	Clock           clock.Clock
}

Config defines the operation of a Worker.

func (Config) Validate

func (config Config) Validate() error

Validate returns an error if config cannot drive a Worker.

type Facade

type Facade interface {
	// Watch returns a watcher which reports when a migration is
	// active for the model associated with the API connection.
	Watch(context.Context) (watcher.NotifyWatcher, error)

	// MigrationStatus returns the details and progress of the latest
	// model migration.
	MigrationStatus(context.Context) (coremigration.MigrationStatus, error)

	// SetPhase updates the phase of the currently active model
	// migration.
	SetPhase(context.Context, coremigration.Phase) error

	// SetStatusMessage sets a human readable message regarding the
	// progress of a migration.
	SetStatusMessage(context.Context, string) error

	// Prechecks performs pre-migration checks on the model and
	// (source) controller.
	Prechecks(context.Context) error

	// ModelInfo return basic information about the model to migrated.
	ModelInfo(context.Context) (coremigration.ModelInfo, error)

	// SourceControllerInfo returns connection information about the source controller
	// and uuids of any other hosted models involved in cross model relations.
	SourceControllerInfo(context.Context) (coremigration.SourceControllerInfo, []string, error)

	// Export returns a serialized representation of the model
	// associated with the API connection.
	Export(context.Context) (coremigration.SerializedModel, error)

	// ProcessRelations runs a series of processes to ensure that the relations
	// of a given model are correct after a migrated model.
	ProcessRelations(context.Context, string) error

	// OpenResource downloads a single resource for an application.
	OpenResource(context.Context, string, string) (io.ReadCloser, error)

	// Reap removes all documents of the model associated with the API
	// connection.
	Reap(context.Context) error

	// WatchMinionReports returns a watcher which reports when a migration
	// minion has made a report for the current migration phase.
	WatchMinionReports(context.Context) (watcher.NotifyWatcher, error)

	// MinionReports returns details of the reports made by migration
	// minions to the controller for the current migration phase.
	MinionReports(context.Context) (coremigration.MinionReports, error)

	// MinionReportTimeout returns the maximum time to wait for minion workers
	// to report on a migration phase.
	MinionReportTimeout(context.Context) (time.Duration, error)

	// StreamModelLog takes a starting time and returns a channel that
	// will yield the logs on or after that time - these are the logs
	// that need to be transferred to the target after the migration
	// is successful.
	StreamModelLog(context.Context, time.Time) (<-chan common.LogMessage, error)
}

Facade exposes controller functionality to a Worker.

func NewFacade

func NewFacade(apiCaller base.APICaller) (Facade, error)

NewFacade attempts to create a new facade for the migration master

type ManifoldConfig

type ManifoldConfig struct {
	AgentName          string
	APICallerName      string
	DomainServicesName string
	FortressName       string

	Clock     clock.Clock
	NewFacade func(base.APICaller) (Facade, error)
	NewWorker func(Config) (worker.Worker, error)
}

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

func (ManifoldConfig) Validate

func (config ManifoldConfig) Validate() error

Validate is called by start to check for bad configuration.

type Worker

type Worker struct {
	// contains filtered or unexported fields
}

Worker waits until a migration is active and its configured Fortress is locked down, and then orchestrates a model migration.

func New

func New(config Config) (*Worker, error)

New returns a Worker backed by config, or an error.

func (*Worker) Kill

func (w *Worker) Kill()

Kill implements worker.Worker.

func (*Worker) Wait

func (w *Worker) Wait() error

Wait implements worker.Worker.

Jump to

Keyboard shortcuts

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