Documentation
¶
Overview ¶
The upgrades package provides infrastructure to upgrade previous Juju deployments to the current Juju version. The upgrade is performed on a per node basis, across all of the running Juju machines.
Important exported APIs include:
PerformUpgrade, which is invoked on each node by the machine agent with: fromVersion - the Juju version from which the upgrade is occurring target - the type of Juju node being upgraded context - provides API access to Juju controllers
Index ¶
- Constants
- Variables
- func PerformUpgrade(from version.Number, targets []Target, context Context) error
- func PreUpgradeSteps(st *state.State, agentConf agent.Config, isController, isMaster bool) error
- type Context
- type Model
- type Operation
- type OperationSource
- type PreUpgradeStepsFunc
- type StateBackend
- type Step
- type Target
Constants ¶
const ( // AllMachines applies to any machine. AllMachines = Target("allMachines") // HostMachine is a machine on which units are deployed. HostMachine = Target("hostMachine") // Controller is a machine participating in a Juju controller cluster. Controller = Target("controller") // DatabaseMaster is a Controller that has the master database, and as such // is the only target that should run database schema upgrade steps. DatabaseMaster = Target("databaseMaster") )
Variables ¶
var MinDiskSpaceMib = uint64(250)
We'll be conservative and require at least 250MiB of disk space for an upgrade.
Functions ¶
func PerformUpgrade ¶
PerformUpgrade runs the business logic needed to upgrade the current "from" version to this version of Juju on the "target" type of machine.
Types ¶
type Context ¶
type Context interface {
// APIState returns an API connection to state.
//
// TODO(mjs) - for 2.0, this should return a base.APICaller
// instead of api.Connection once the 1.x upgrade steps have been
// removed. Upgrade steps should not be able close the API
// connection.
APIState() api.Connection
// State returns a connection to state. This will be non-nil
// only in the context of a controller.
State() StateBackend
// AgentConfig returns the agent config for the machine that is being
// upgraded.
AgentConfig() agent.ConfigSetter
// StateContext returns a new Context suitable for State-based
// upgrade steps.
StateContext() Context
// APIContext returns a new Context suitable for API-based upgrade
// steps.
APIContext() Context
// NewEnviron returns a new Environ given a State. This is used
// for upgrading Environs.
NewEnviron(environs.OpenParams) (environs.Environ, error)
}
Context provides the dependencies used when executing upgrade steps.
func NewContext ¶
func NewContext( agentConfig agent.ConfigSetter, api api.Connection, st StateBackend, newEnviron environs.NewEnvironFunc, ) Context
NewContext returns a new upgrade context.
type Model ¶
Model is an interface providing access to the details of a model within the controller.
type Operation ¶
type Operation interface {
// The Juju version for which this operation is applicable.
// Upgrade operations designed for versions of Juju earlier
// than we are upgrading from are not run since such steps would
// already have been used to get to the version we are running now.
TargetVersion() version.Number
// Steps to perform during an upgrade.
Steps() []Step
}
Operation defines what steps to perform to upgrade to a target version.
type OperationSource ¶
type OperationSource interface {
// UpgradeOperations returns Operations to run during upgrade.
UpgradeOperations() []Operation
}
OperationSource provides a means of obtaining upgrade operations.
type PreUpgradeStepsFunc ¶
PreUpgradeStepsFunc is the function type of PreUpgradeSteps. This may be used to provide an alternative to PreUpgradeSteps to the upgrade steps worker.
type StateBackend ¶
type StateBackend interface {
AllModels() ([]Model, error)
StripLocalUserDomain() error
RenameAddModelPermission() error
DropOldLogIndex() error
AddMigrationAttempt() error
AddLocalCharmSequences() error
UpdateLegacyLXDCloudCredentials(string, cloud.Credential) error
}
StateBackend provides an interface for upgrading the global state database.
func NewStateBackend ¶
func NewStateBackend(st *state.State) StateBackend
NewStateBackend returns a new StateBackend using a *state.State object.
type Step ¶
type Step interface {
// Description is a human readable description of what the upgrade step does.
Description() string
// Targets returns the target machine types for which the upgrade step is applicable.
Targets() []Target
// Run executes the upgrade business logic.
Run(Context) error
}
Step defines an idempotent operation that is run to perform a specific upgrade step.