migrationtarget

package
v0.0.0-...-756137a Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: AGPL-3.0 Imports: 28 Imported by: 2

Documentation

Overview

Package migrationtarget defines the API facade for use by the migration master worker when interacting with the target controller during a migration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(requiredMigrationFacadeVersions facades.FacadeVersions) func(registry facade.FacadeRegistry)

Register is called to expose a package of facades onto a given registry.

Types

type API

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

API implements the API required for the model migration master worker when communicating with the target controller.

func NewAPI

func NewAPI(
	ctx facade.ModelContext,
	authorizer facade.Authorizer,
	controllerConfigService ControllerConfigService,
	externalControllerService ExternalControllerService,
	applicationService ApplicationService,
	upgradeService UpgradeService,
	modelAgentServiceGetter ModelAgentServiceGetter,
	modelMigrationServiceGetter ModelMigrationServiceGetter,
	requiredMigrationFacadeVersions facades.FacadeVersions,
	logDir string,
) (*API, error)

NewAPI returns a new migration target api. Accepts a NewEnvironFunc and envcontext.ProviderCallContext for testing purposes.

func (*API) Abort

func (api *API) Abort(ctx context.Context, args params.ModelArgs) error

Abort removes the specified model from the database. It is an error to attempt to Abort a model that has a migration mode other than importing.

func (*API) Activate

func (api *API) Activate(ctx context.Context, args params.ActivateModelArgs) error

Activate sets the migration mode of the model to "none", meaning it is ready for use. It also adds any required external controller records for those controllers hosting offers used by the model.

func (*API) AdoptResources

func (api *API) AdoptResources(ctx context.Context, args params.AdoptResourcesArgs) error

AdoptResources asks the cloud provider to update the controller tags for a model's resources. This prevents the resources from being destroyed if the source controller is destroyed after the model is migrated away.

func (*API) CACert

func (api *API) CACert(ctx context.Context) (params.BytesResult, error)

CACert returns the certificate used to validate the state connection.

func (*API) CheckMachines

func (api *API) CheckMachines(ctx context.Context, args params.ModelArgs) (params.ErrorResults, error)

CheckMachines compares the machines in state with the ones reported by the provider and reports any discrepancies.

func (*API) Import

func (api *API) Import(ctx context.Context, serialized params.SerializedModel) error

Import takes a serialized Juju model, deserializes it, and recreates it in the receiving controller.

func (*API) LatestLogTime

func (api *API) LatestLogTime(ctx context.Context, args params.ModelArgs) (time.Time, error)

LatestLogTime returns the time of the most recent log record received by the logtransfer endpoint. This can be used as the start point for streaming logs from the source if the transfer was interrupted.

Log messages are assumed to be sent in time order (which is how debug-log emits them). If that isn't the case then this mechanism can't be used to avoid duplicates when logtransfer is restarted.

Returns the zero time if no logs have been transferred.

func (*API) Prechecks

func (api *API) Prechecks(ctx context.Context, model params.MigrationModelInfo) error

Prechecks ensure that the target controller is ready to accept a model migration.

type ApplicationService

type ApplicationService interface {
	// GetApplicationLife returns the life value of the application with the given name.
	GetApplicationLife(ctx context.Context, name string) (life.Value, error)
	// GetUnitWorkloadStatus returns the workload status of the specified unit.
	GetUnitWorkloadStatus(context.Context, unit.Name) (*status.StatusInfo, error)
}

ApplicationService provides access to the application service.

type ControllerConfigService

type ControllerConfigService interface {
	// ControllerConfig returns the controller config.
	ControllerConfig(context.Context) (controller.Config, error)
}

ControllerConfigService provides a subset of the controller config domain service methods.

type ExternalControllerService

type ExternalControllerService interface {
	// ControllerForModel returns the controller record that's associated
	// with the modelUUID.
	ControllerForModel(ctx context.Context, modelUUID string) (*crossmodel.ControllerInfo, error)

	// UpdateExternalController persists the input controller
	// record.
	UpdateExternalController(ctx context.Context, ec crossmodel.ControllerInfo) error
}

ExternalControllerService provides a subset of the external controller domain service methods.

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 ModelAgentServiceGetter

type ModelAgentServiceGetter func(modelId coremodel.UUID) ModelAgentService

ModelAgentServiceGetter describes a function that is able to return the ModelAgentService for a given model id.

type ModelImporter

type ModelImporter interface {
	// ImportModel takes a serialized description model (yaml bytes) and returns
	// a state model and state state.
	ImportModel(ctx context.Context, bytes []byte) (*state.Model, *state.State, error)
}

ModelImporter defines an interface for importing models.

type ModelManagerService

type ModelManagerService interface {
	Create(context.Context, coremodel.UUID) error
}

ModelManagerService describes the method needed to update model metadata.

type ModelMigrationService

type ModelMigrationService interface {
	// AdoptResources is responsible for taking ownership of the cloud resources
	// of a model when it has been migrated into this controller.
	AdoptResources(context.Context, version.Number) error

	// CheckMachines is responsible for checking a model after it has been
	// migrated into this target controller. We check the machines that exist in
	// the model against the machines reported by the models cloud and report
	// any discrepancies.
	CheckMachines(context.Context) ([]modelmigration.MigrationMachineDiscrepancy, error)
}

ModelMigrationService provides the means for supporting model migration actions between controllers and answering questions about the underlying model(s) that are being migrated.

type ModelMigrationServiceGetter

type ModelMigrationServiceGetter func(coremodel.UUID) ModelMigrationService

ModelMigrationServiceGetter describes a function that is able to return the ModelMigrationService for a given model id.

type UpgradeService

type UpgradeService interface {
	// IsUpgrading returns whether the controller is currently upgrading.
	IsUpgrading(context.Context) (bool, error)
}

UpgradeService provides a subset of the upgrade domain service methods.

Jump to

Keyboard shortcuts

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