Documentation
¶
Index ¶
- func ControllerDialOpts() api.DialOpts
- func ImportPrecheck(ctx context.Context, model description.Model) error
- func SourcePrecheck(ctx context.Context, backend PrecheckBackend, modelPresence ModelPresence, ...) error
- func TargetPrecheck(ctx context.Context, backend PrecheckBackend, pool Pool, ...) error
- func UploadBinaries(ctx context.Context, config UploadBinariesConfig, logger corelogger.Logger) error
- type ApplicationService
- type CharmService
- type CharmUploader
- type ConfigSchemaSourceProvider
- type ControllerConfigService
- type Coordinator
- type CredentialService
- type LegacyStateExporter
- type ModelAgentService
- type ModelExporter
- func (e *ModelExporter) Export(ctx context.Context, model description.Model) (description.Model, error)
- func (e *ModelExporter) ExportModel(ctx context.Context, leaders map[string]string, store objectstore.ObjectStore) (description.Model, error)
- func (e *ModelExporter) ExportModelPartial(ctx context.Context, cfg state.ExportConfig, store objectstore.ObjectStore) (description.Model, error)
- type ModelImporter
- type ModelPresence
- type OperationExporter
- type Pool
- type PrecheckApplication
- type PrecheckBackend
- type PrecheckMachine
- type PrecheckModel
- type PrecheckRelation
- type PrecheckRelationUnit
- type PrecheckUnit
- type ResourceDownloader
- type ResourceUploader
- type ToolsDownloader
- type ToolsUploader
- type UpgradeService
- type UploadBinariesConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ControllerDialOpts ¶
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 ImportPrecheck ¶
ImportPrecheck checks the data being imported to make sure preconditions for importing are met.
func SourcePrecheck ¶
func SourcePrecheck( ctx context.Context, backend PrecheckBackend, modelPresence ModelPresence, controllerPresence ModelPresence, environscloudspecGetter environsCloudSpecGetter, credentialService CredentialService, upgradeService UpgradeService, applicationService ApplicationService, modelAgentService ModelAgentService, ) 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(ctx context.Context, backend PrecheckBackend, pool Pool, modelInfo coremigration.ModelInfo, presence ModelPresence, upgradeService UpgradeService, applicationService ApplicationService, modelAgentService ModelAgentService, ) 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(ctx context.Context, config UploadBinariesConfig, logger corelogger.Logger) error
UploadBinaries will send binaries stored in the source blobstore to the target controller.
Types ¶
type ApplicationService ¶
type ApplicationService interface {
GetApplicationLife(context.Context, string) (life.Value, error)
}
ApplicationService provides access to the application service.
type CharmService ¶
type CharmService interface { // GetCharmArchive returns a ReadCloser stream for the charm archive for a given // charm id, along with the hash of the charm archive. Clients can use the hash // to verify the integrity of the charm archive. GetCharmArchive(context.Context, domaincharm.CharmLocator) (io.ReadCloser, string, error) }
type CharmUploader ¶
type CharmUploader interface {
UploadCharm(ctx context.Context, charmURL string, charmRef string, content io.Reader) (string, error)
}
CharmUploader defines a single method that is used to upload a charm to the target controller in a migration.
type ConfigSchemaSourceProvider ¶
type ConfigSchemaSourceProvider = func(environs.CloudService) config.ConfigSchemaSourceGetter
ConfigSchemaSourceProvider returns a config.ConfigSchemaSourceGetter based on the given cloud service.
type ControllerConfigService ¶
type ControllerConfigService interface {
ControllerConfig(context.Context) (controller.Config, error)
}
ControllerConfigService describes the method needed to get the controller config.
type Coordinator ¶
type Coordinator interface { // Add a new operation to the migration. It will be appended at the end of the // list of operations. Add(operations modelmigration.Operation) // Perform executes the migration. // We log in addition to returning errors because the error is ultimately // returned to the caller on the source, and we want them to be reflected // in *this* controller's logs. Perform(ctx context.Context, scope modelmigration.Scope, model description.Model) (err error) }
Coordinator describes the interface required for coordinating model migration operations.
type CredentialService ¶
type CredentialService interface {
CloudCredential(ctx context.Context, key credential.Key) (cloud.Credential, error)
}
CredentialService provides access to credentials.
type LegacyStateExporter ¶
type LegacyStateExporter interface { // Export generates an abstract representation of a model. Export(leaders map[string]string, store objectstore.ObjectStore) (description.Model, error) // ExportPartial produces a partial export based based on the input // config. ExportPartial(cfg state.ExportConfig, store objectstore.ObjectStore) (description.Model, error) }
LegacyStateExporter describes interface on state required to export a model. Deprecated: This is being replaced with the ModelExporter.
type ModelAgentService ¶
type ModelAgentService interface { // GetModelTargetAgentVersion returns the target agent version for the // entire model. The following errors can be returned: // - [github.com/juju/juju/domain/model/errors.NotFound] - When the model does // not exist. GetModelTargetAgentVersion(context.Context) (version.Number, error) }
ModelAgentService provides access to the Juju agent version for the model.
type ModelExporter ¶
type ModelExporter struct {
// contains filtered or unexported fields
}
ModelExporter facilitates partial and full export of a model.
func NewModelExporter ¶
func NewModelExporter( operationExporter OperationExporter, legacyStateExporter LegacyStateExporter, scope modelmigration.Scope, storageRegistryGetter corestorage.ModelStorageRegistryGetter, coordinator Coordinator, logger corelogger.Logger, clock clock.Clock, ) *ModelExporter
NewModelExporter returns a new ModelExporter that encapsulates the legacyStateExporter. The legacyStateExporter is being deprecated, only needed until the migration to dqlite is complete.
func (*ModelExporter) Export ¶
func (e *ModelExporter) Export(ctx context.Context, model description.Model) (description.Model, error)
Export serializes a model description from the database contents.
func (*ModelExporter) ExportModel ¶
func (e *ModelExporter) ExportModel(ctx context.Context, leaders map[string]string, store objectstore.ObjectStore) (description.Model, error)
ExportModel serializes a model description from the database (legacy mongodb plus dqlite) contents.
func (*ModelExporter) ExportModelPartial ¶
func (e *ModelExporter) ExportModelPartial(ctx context.Context, cfg state.ExportConfig, store objectstore.ObjectStore) (description.Model, error)
ExportModelPartial partially serializes a model description from the database (legacy mongodb plus dqlite) contents, optionally skipping aspects as defined by the ExportConfig.
type ModelImporter ¶
type ModelImporter struct {
// contains filtered or unexported fields
}
ModelImporter represents a model migration that implements Import.
func NewModelImporter ¶
func NewModelImporter( stateImporter legacyStateImporter, scope modelmigration.ScopeForModel, controllerConfigService ControllerConfigService, domainServices services.DomainServicesGetter, storageRegistryGetter corestorage.ModelStorageRegistryGetter, objectStoreGetter objectstore.ModelObjectStoreGetter, logger corelogger.Logger, clock clock.Clock, ) *ModelImporter
NewModelImporter returns a new ModelImporter that encapsulates the legacyStateImporter. The legacyStateImporter is being deprecated, only needed until the migration to dqlite is complete.
func (*ModelImporter) ImportModel ¶
func (i *ModelImporter) ImportModel(ctx context.Context, 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.
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 OperationExporter ¶
type OperationExporter interface { // ExportOperations registers the export operations with the given coordinator. ExportOperations(registry corestorage.ModelStorageRegistryGetter) }
OperationExporter describes the interface for running the ExportOpertions method.
type Pool ¶
type Pool interface {
GetModel(string) (PrecheckModel, func(), error)
}
Pool defines the interface to a StatePool used by the migration prechecks.
type PrecheckApplication ¶
type PrecheckApplication interface { Name() string CharmURL() (*string, bool) AllUnits() ([]PrecheckUnit, error) }
PrecheckApplication describes the state interface for an application needed by migration prechecks.
type PrecheckBackend ¶
type PrecheckBackend interface { NeedsCleanup() (bool, error) Model() (PrecheckModel, error) AllModelUUIDs() ([]string, error) IsMigrationActive(string) (bool, error) AllMachines() ([]PrecheckMachine, error) AllMachinesCount() (int, error) AllApplications() ([]PrecheckApplication, error) AllRelations() ([]PrecheckRelation, error) ControllerBackend() (PrecheckBackend, 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) }
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 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() []relation.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 }
PrecheckUnit describes state interface for a unit needed by migration prechecks.
type ResourceDownloader ¶
type ResourceDownloader interface {
OpenResource(context.Context, 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(context.Context, resource.Resource, io.Reader) error
}
ResourceUploader defines the interface for uploading resources into the target controller during a migration.
type ToolsDownloader ¶
type ToolsDownloader interface {
OpenURI(context.Context, 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(context.Context, io.Reader, version.Binary) (tools.List, error)
}
ToolsUploader defines a single method that is used to upload tools to the target controller in a migration.
type UpgradeService ¶
UpgradeService provides access to upgrade information.
type UploadBinariesConfig ¶
type UploadBinariesConfig struct { Charms []string CharmService CharmService 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.