Documentation
¶
Overview ¶
Package upgrade state provides a type for representing the state of an upgrade.
The states are represented as a finite state machine, with the following transitions:
┌──────────────────┐ │ Created ├─────┐ └─────────┬────────┘ │ │ │ │ │ ┌─────────▼─────────┐ │ │ Started ├────┤ └─────────┬─────────┘ │ │ │ ┌───────────┐ │ ├────► Error │ ┌─────────▼─────────┐ │ └───────────┘ │ DBCompleted ├────┤ └─────────┬─────────┘ │ │ │ │ │ ┌─────────▼─────────┐ │ │ StepsCompleted ├────┘ └───────────────────┘
The state machine is represented by the State type, which is an integer type. The constants for the states are exported, and the type is exported so that it can be used in APIs.
Index ¶
- type ControllerNodeInfo
- type Count
- type Info
- type State
- func (st *State) ActiveUpgrade(ctx context.Context) (domainupgrade.UUID, error)
- func (st *State) AllProvisionedControllersReady(ctx context.Context, upgradeUUID domainupgrade.UUID) (bool, error)
- func (st *State) CreateUpgrade(ctx context.Context, previousVersion, targetVersion version.Number) (domainupgrade.UUID, error)
- func (st *State) SetControllerDone(ctx context.Context, upgradeUUID domainupgrade.UUID, controllerID string) error
- func (st *State) SetControllerReady(ctx context.Context, upgradeUUID domainupgrade.UUID, controllerID string) error
- func (st *State) SetDBUpgradeCompleted(ctx context.Context, upgradeUUID domainupgrade.UUID) error
- func (st *State) SetDBUpgradeFailed(ctx context.Context, upgradeUUID domainupgrade.UUID) error
- func (st *State) StartUpgrade(ctx context.Context, upgradeUUID domainupgrade.UUID) error
- func (st *State) UpgradeInfo(ctx context.Context, upgradeUUID domainupgrade.UUID) (upgrade.Info, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ControllerNodeInfo ¶
type ControllerNodeInfo struct { // UUID holds the rows UUID. UUID string `db:"uuid"` // UpgradeInfoUUID holds the UUID of the associated upgrade info. UpgradeInfoUUID string `db:"upgrade_info_uuid"` // ControllerNodeID holds the controller node ID ControllerNodeID string `db:"controller_node_id"` // NodeUpgradeStartedAt holds the time the upgrade was started on the node NodeUpgradeCompletedAt sql.NullString `db:"node_upgrade_completed_at"` }
ControllerNodeInfo holds the information about completeness of database upgrade process for a particular controller node
type Count ¶
type Count struct {
Num int `db:"num"`
}
Count is used to select counts from the database.
type Info ¶
type Info struct { // UUID holds the upgrader's ID UUID string `db:"uuid"` // PreviousVersion holds the previous version PreviousVersion string `db:"previous_version"` // TargetVersion holds the target version TargetVersion string `db:"target_version"` // StateIDType holds the type id of the current state of the upgrade. StateIDType int `db:"state_type_id"` }
Info holds the information about database upgrade
type State ¶
State is used to access the database.
func NewState ¶
func NewState(factory coredatabase.TxnRunnerFactory) *State
NewState creates a state to access the database.
func (*State) ActiveUpgrade ¶
ActiveUpgrade returns the uuid of the active upgrade. The active upgrade is any upgrade that is not in the StepsCompleted state. It returns a NotFound error if there is no active upgrade.
func (*State) AllProvisionedControllersReady ¶
func (st *State) AllProvisionedControllersReady(ctx context.Context, upgradeUUID domainupgrade.UUID) (bool, error)
AllProvisionedControllersReady returns true if and only if all controllers that have been started by the provisioner are ready to start the provided upgrade.
func (*State) CreateUpgrade ¶
func (st *State) CreateUpgrade(ctx context.Context, previousVersion, targetVersion version.Number) (domainupgrade.UUID, error)
CreateUpgrade creates an active upgrade to and from specified versions and returns the upgrade's UUID. If an active upgrade already exists, return an AlreadyExists error
func (*State) SetControllerDone ¶
func (st *State) SetControllerDone(ctx context.Context, upgradeUUID domainupgrade.UUID, controllerID string) error
SetControllerDone marks the supplied controllerID as having completed its upgrades. When SetControllerDone is called by the all provisioned controller, the upgrade itself will be completed.
TODO (jack-w-shaw) Set `statuses`/`statuseshistory` here to status.Available when we complete an upgrade
func (*State) SetControllerReady ¶
func (st *State) SetControllerReady(ctx context.Context, upgradeUUID domainupgrade.UUID, controllerID string) error
SetControllerReady marks the supplied controllerID as being ready to start a provided upgrade. All provisioned controllers need to be ready before an upgrade can start. A controller node is ready for an upgrade if a row corresponding to the controller is present in upgrade_info_controller_node.
func (*State) SetDBUpgradeCompleted ¶
SetDBUpgradeCompleted marks the database upgrade as completed.
func (*State) SetDBUpgradeFailed ¶
SetDBUpgradeFailed marks the database upgrade as failed.
func (*State) StartUpgrade ¶
StartUpgrade starts the provided upgrade if the upgrade already exists. If it does not exists it returns a NotFound error. If it's already started, it returns a AlreadyStarted error.
TODO (jack-w-shaw) Set `statuses`/`statuseshistory` here to status.Busy once the table has been added
func (*State) UpgradeInfo ¶
func (st *State) UpgradeInfo(ctx context.Context, upgradeUUID domainupgrade.UUID) (upgrade.Info, error)
UpgradeInfo returns the upgrade info for the provided upgradeUUID. It returns a NotFound error if the upgrade does not exist.