migration

package
v0.0.0-...-3d086f3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: AGPL-3.0 Imports: 27 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ControllerDialOpts

func ControllerDialOpts() api.DialOpts

ControllerDialOpts returns dial parameters suitable for connecting from the source controller to the target controller during model migrations. Except for the inclusion of RetryDelay the options mirror what is used by the APICaller for logins.

func ImportModel

func ImportModel(importer StateImporter, getClaimer ClaimerFunc, bytes []byte) (*state.Model, *state.State, error)

ImportModel deserializes a model description from the bytes, transforms the model config based on information from the controller model, and then imports that as a new database model.

func SourcePrecheck

func SourcePrecheck(
	backend PrecheckBackend,
	modelPresence ModelPresence, controllerPresence ModelPresence,
	environscloudspecGetter environsCloudSpecGetter,
) error

SourcePrecheck checks the state of the source controller to make sure that the preconditions for model migration are met. The backend provided must be for the model to be migrated.

func TargetPrecheck

func TargetPrecheck(backend PrecheckBackend, pool Pool, modelInfo coremigration.ModelInfo, presence ModelPresence) error

TargetPrecheck checks the state of the target controller to make sure that the preconditions for model migration are met. The backend provided must be for the target controller.

func UploadBinaries

func UploadBinaries(config UploadBinariesConfig) error

UploadBinaries will send binaries stored in the source blobstore to the target controller.

Types

type CharmDownloader

type CharmDownloader interface {
	OpenCharm(string) (io.ReadCloser, error)
}

CharmDownloader defines a single method that is used to download a charm from the source controller in a migration.

type CharmUploader

type CharmUploader interface {
	UploadCharm(charmURL string, charmRef string, content io.ReadSeeker) (string, error)
}

CharmUploader defines a single method that is used to upload a charm to the target controller in a migration.

type ClaimerFunc

type ClaimerFunc func(string) (leadership.Claimer, error)

ClaimerFunc is a function that returns a leadership claimer for the model UUID passed.

type ModelPresence

type ModelPresence interface {
	// For a given non controller agent, return the Status for that agent.
	AgentStatus(agent string) (presence.Status, error)
}

ModelPresence represents the API server connections for a model.

type Pool

type Pool interface {
	GetModel(string) (PrecheckModel, func(), error)
}

Pool defines the interface to a StatePool used by the migration prechecks.

func PoolShim

func PoolShim(pool *state.StatePool) Pool

PoolShim wraps a state.StatePool to produce a Pool.

type PrecheckApplication

type PrecheckApplication interface {
	Name() string
	Life() state.Life
	CharmURL() (*string, bool)
	AllUnits() ([]PrecheckUnit, error)
	MinUnits() int
}

PrecheckApplication describes the state interface for an application needed by migration prechecks.

type PrecheckBackend

type PrecheckBackend interface {
	AgentVersion() (version.Number, error)
	NeedsCleanup() (bool, error)
	Model() (PrecheckModel, error)
	AllModelUUIDs() ([]string, error)
	IsUpgrading() (bool, error)
	IsMigrationActive(string) (bool, error)
	AllMachines() ([]PrecheckMachine, error)
	AllApplications() ([]PrecheckApplication, error)
	AllRelations() ([]PrecheckRelation, error)
	AllCharmURLs() ([]*string, error)
	ControllerBackend() (PrecheckBackend, error)
	CloudCredential(tag names.CloudCredentialTag) (state.Credential, error)
	HasUpgradeSeriesLocks() (bool, error)
	MachineCountForBase(base ...state.Base) (map[string]int, error)
	MongoCurrentStatus() (*replicaset.Status, error)
}

PrecheckBackend defines the interface to query Juju's state for migration prechecks.

func PrecheckShim

func PrecheckShim(modelState, controllerState *state.State) (PrecheckBackend, error)

PrecheckShim wraps a pair of *state.States to implement PrecheckBackend.

type PrecheckMachine

type PrecheckMachine interface {
	Id() string
	AgentTools() (*tools.Tools, error)
	Life() state.Life
	Status() (status.StatusInfo, error)
	InstanceStatus() (status.StatusInfo, error)
	ShouldRebootOrShutdown() (state.RebootAction, error)
}

PrecheckMachine describes the state interface for a machine needed by migration prechecks.

type PrecheckModel

type PrecheckModel interface {
	UUID() string
	Name() string
	Type() state.ModelType
	Owner() names.UserTag
	Life() state.Life
	MigrationMode() state.MigrationMode
	AgentVersion() (version.Number, error)
	CloudCredentialTag() (names.CloudCredentialTag, bool)
}

PrecheckModel describes the state interface a model as needed by the migration prechecks.

type PrecheckRelation

type PrecheckRelation interface {
	String() string
	Endpoints() []state.Endpoint
	Unit(PrecheckUnit) (PrecheckRelationUnit, error)
	AllRemoteUnits(appName string) ([]PrecheckRelationUnit, error)
	RemoteApplication() (string, bool, error)
}

PrecheckRelation describes the state interface for relations needed for prechecks.

type PrecheckRelationUnit

type PrecheckRelationUnit interface {
	Valid() (bool, error)
	InScope() (bool, error)
	UnitName() string
}

PrecheckRelationUnit describes the interface for relation units needed for migration prechecks.

type PrecheckUnit

type PrecheckUnit interface {
	Name() string
	AgentTools() (*tools.Tools, error)
	Life() state.Life
	CharmURL() *string
	AgentStatus() (status.StatusInfo, error)
	Status() (status.StatusInfo, error)
	ShouldBeAssigned() bool
	IsSidecar() (bool, error)
}

PrecheckUnit describes state interface for a unit needed by migration prechecks.

type ResourceDownloader

type ResourceDownloader interface {
	OpenResource(string, string) (io.ReadCloser, error)
}

ResourceDownloader defines the interface for downloading resources from the source controller during a migration.

type ResourceUploader

type ResourceUploader interface {
	UploadResource(resources.Resource, io.ReadSeeker) error
	SetPlaceholderResource(resources.Resource) error
	SetUnitResource(string, resources.Resource) error
}

ResourceUploader defines the interface for uploading resources into the target controller during a migration.

type StateExporter

type StateExporter interface {
	// Export generates an abstract representation of a model.
	Export(leaders map[string]string) (description.Model, error)
}

StateExporter describes interface on state required to export a model.

type StateImporter

type StateImporter interface {
	Import(model description.Model) (*state.Model, *state.State, error)
}

StateImporter describes the method needed to import a model into the database.

type ToolsDownloader

type ToolsDownloader interface {
	OpenURI(string, url.Values) (io.ReadCloser, error)
}

ToolsDownloader defines a single method that is used to download tools from the source controller in a migration.

type ToolsUploader

type ToolsUploader interface {
	UploadTools(io.ReadSeeker, version.Binary) (tools.List, error)
}

ToolsUploader defines a single method that is used to upload tools to the target controller in a migration.

type UploadBinariesConfig

type UploadBinariesConfig struct {
	Charms          []string
	CharmDownloader CharmDownloader
	CharmUploader   CharmUploader

	Tools           map[version.Binary]string
	ToolsDownloader ToolsDownloader
	ToolsUploader   ToolsUploader

	Resources          []migration.SerializedModelResource
	ResourceDownloader ResourceDownloader
	ResourceUploader   ResourceUploader
}

UploadBinariesConfig provides all the configuration that the UploadBinaries function needs to operate. To construct the config with the default helper functions, use `NewUploadBinariesConfig`.

func (*UploadBinariesConfig) Validate

func (c *UploadBinariesConfig) Validate() error

Validate makes sure that all the config values are non-nil.

Jump to

Keyboard shortcuts

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