modelupgrader

package
v0.0.0-...-b0bff92 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrModelRemoved = errors.New("model has been removed")

ErrModelRemoved indicates that this worker was operating on the model that is no longer found.

Functions

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency.Manifold that will run a Worker as configured.

func NewWorker

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

NewWorker returns a worker that ensures that environ/provider schema upgrades are run when the model is first loaded by a controller of a new version. The worker either runs the upgrades or waits for another controller unit to run them, depending on the configuration.

Types

type Config

type Config struct {
	// Facade holds the API facade used by this worker for getting,
	// setting and watching the model's environ version.
	Facade Facade

	// GateUnlocker holds a gate.Unlocker that the worker must call
	// after the model has been successfully upgraded.
	GateUnlocker gate.Unlocker

	// ControllerTag holds the tag of the controller that runs this
	// worker.
	ControllerTag names.ControllerTag

	// ModelTag holds the tag of the model to which this worker is
	// scoped.
	ModelTag names.ModelTag

	// Environ holds the Environ used to run upgrade steps, or nil
	// if the worker should wait for upgrade steps to be run by
	// another agent.
	Environ environs.Environ

	// CredentialAPI holds the API facade used to invalidate credential
	// whenever the worker makes cloud calls if credential for this model
	// becomes invalid.
	CredentialAPI common.CredentialAPI

	Logger Logger
}

Config holds the configuration and dependencies for a worker.

func (Config) Validate

func (config Config) Validate() error

Validate returns an error if the config cannot be expected to drive a functional worker.

type Facade

type Facade interface {
	ModelEnvironVersion(tag names.ModelTag) (int, error)
	ModelTargetEnvironVersion(tag names.ModelTag) (int, error)
	SetModelEnvironVersion(tag names.ModelTag, v int) error
	SetModelStatus(names.ModelTag, status.Status, string, map[string]interface{}) error
	WatchModelEnvironVersion(tag names.ModelTag) (watcher.NotifyWatcher, error)
}

Facade exposes capabilities required by the worker.

func NewFacade

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

type Logger

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

Logger represents the methods used by the worker to log details.

type ManifoldConfig

type ManifoldConfig struct {
	APICallerName string
	EnvironName   string
	GateName      string
	ControllerTag names.ControllerTag
	ModelTag      names.ModelTag
	Logger        Logger

	NewFacade                    func(base.APICaller) (Facade, error)
	NewWorker                    func(Config) (worker.Worker, error)
	NewCredentialValidatorFacade func(base.APICaller) (common.CredentialAPI, error)
}

ManifoldConfig describes how to configure and construct a Worker, and what registered resources it may depend upon.

Jump to

Keyboard shortcuts

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