Documentation ¶
Overview ¶
This file implements richer support for working with operation phases
This file implements a generic FSM update engine ¶
Copyright 2018 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
This file implements a controller to run an update operation
Index ¶
- func NewMachine(ctx context.Context, config Config, engine *Engine) (*fsm.FSM, error)
- func ResolvePlan(plan *storage.OperationPlan)
- func Retry(ctx context.Context, fn func() error, timeout time.Duration) error
- func SplitServers(servers []storage.UpdateServer) (masters, nodes []storage.UpdateServer)
- func SyncChangelog(src storage.Backend, dst storage.Backend, clusterName string, ...) error
- func SyncOperationPlan(src storage.Backend, dst storage.Backend, plan storage.OperationPlan, ...) error
- func WaitForEndpoints(ctx context.Context, client corev1.CoreV1Interface, server storage.Server) error
- type Config
- type Dispatcher
- type Engine
- func (r *Engine) ChangePhaseState(ctx context.Context, change fsm.StateChange) error
- func (r *Engine) Complete(ctx context.Context, fsmErr error) error
- func (r *Engine) GetExecutor(params fsm.ExecutorParams, remote fsm.Remote) (fsm.PhaseExecutor, error)
- func (r *Engine) GetPlan() (*storage.OperationPlan, error)
- func (r *Engine) RunCommand(ctx context.Context, runner rpc.RemoteRunner, server storage.Server, ...) error
- func (r *Engine) UpdateProgress(ctx context.Context, params fsm.Params) error
- type LocalPackageService
- type ParentPhase
- type Phase
- func (p *Phase) Add(subs ...Phase)
- func (p *Phase) AddParallel(subs ...Phase)
- func (p *Phase) AddSequential(subs ...Phase)
- func (p *Phase) AddWithDependency(dep PhaseIder, subs ...Phase)
- func (p *Phase) Child(sub Phase) string
- func (p *Phase) ChildLiteral(sub string) string
- func (p Phase) GetID() string
- func (p *Phase) Require(reqs ...PhaseIder) *Phase
- func (p *Phase) RequireLiteral(ids ...string) *Phase
- type PhaseIder
- type PhaseRef
- type Phases
- type Reconciler
- type Updater
- func (r *Updater) Activate() error
- func (r *Updater) Check(params fsm.Params) error
- func (r *Updater) Close() error
- func (r *Updater) Complete(ctx context.Context, fsmErr error) error
- func (r *Updater) GetPlan() (*storage.OperationPlan, error)
- func (r *Updater) RollbackPhase(ctx context.Context, params fsm.Params, phaseTimeout time.Duration) error
- func (r *Updater) Run(ctx context.Context) (err error)
- func (r *Updater) RunPhase(ctx context.Context, phase string, phaseTimeout time.Duration, force bool) error
- func (r *Updater) SetPhase(ctx context.Context, phase, state string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMachine ¶
NewMachine returns a new state machine for an update operation.
func ResolvePlan ¶
func ResolvePlan(plan *storage.OperationPlan)
ResolvePlan resolves dependencies between phases and renders IDs as absolute in the specified plan
func Retry ¶
Retry runs the specified function fn. If the function fails, it is retried for the given timeout using exponential backoff
func SplitServers ¶
func SplitServers(servers []storage.UpdateServer) (masters, nodes []storage.UpdateServer)
SplitServers splits the specified server list into servers with master cluster role and regular nodes.
func SyncChangelog ¶
func SyncChangelog(src storage.Backend, dst storage.Backend, clusterName string, operationID string) error
SyncChangelog will sync changelog entries from src to dst storage
func SyncOperationPlan ¶
func SyncOperationPlan(src storage.Backend, dst storage.Backend, plan storage.OperationPlan, operation storage.SiteOperation) error
SyncOperationPlan will synchronize the specified operation and its plan from source to destination backend
func WaitForEndpoints ¶
func WaitForEndpoints(ctx context.Context, client corev1.CoreV1Interface, server storage.Server) error
WaitForEndpoints waits for service endpoints to become active for the server specified with nodeID. nodeID is assumed to be the name of the node as accepted by Kubernetes
Types ¶
type Config ¶
type Config struct { // Operation references the update operation Operation *ops.SiteOperation // Operator is the cluster operator service Operator ops.Operator // Backend specifies the cluster backend Backend storage.Backend // LocalBackend specifies the authoritative source for operation state LocalBackend storage.Backend // Runner specifies the runner for remote commands Runner rpc.AgentRepository // FieldLogger is the logger to use log.FieldLogger // Silent controls whether the process outputs messages to stdout localenv.Silent }
Config describes configuration for executing an update operation
func (*Config) CheckAndSetDefaults ¶
CheckAndSetDefaults validates this object and sets defaults where necessary
type Dispatcher ¶
type Dispatcher interface { // Dispatch returns an executor for the given parameters and the specified remote Dispatch(fsm.ExecutorParams, fsm.Remote) (fsm.PhaseExecutor, error) }
Dispatcher routes the set of execution parameters to a specific operation phase
type Engine ¶
type Engine struct { // Config specifies engine configuration Config // Silent controls whether the log output is verbose localenv.Silent // contains filtered or unexported fields }
Engine is the updater engine
func NewEngine ¶
NewEngine returns a new update engine using the given dispatcher to dispatch phases
func (*Engine) ChangePhaseState ¶
ChangePhaseState creates a new changelog entry
func (*Engine) Complete ¶
Complete marks the operation as either completed or failed based on the state of the operation plan
func (*Engine) GetExecutor ¶
func (r *Engine) GetExecutor(params fsm.ExecutorParams, remote fsm.Remote) (fsm.PhaseExecutor, error)
GetExecutor returns a new executor based on the provided parameters
func (*Engine) GetPlan ¶
func (r *Engine) GetPlan() (*storage.OperationPlan, error)
GetPlan returns the most up-to-date operation plan
type LocalPackageService ¶
type LocalPackageService interface { pack.PackageService UnpackedPath(loc.Locator) (path string, err error) UnpackWithOptions(loc loc.Locator, targetDir string, opts *archive.TarOptions) error GetPackageManifest(loc loc.Locator) (*pack.Manifest, error) }
LocalPackageService defines a package service on local host
type ParentPhase ¶
type Phase ¶
type Phase storage.OperationPhase
Phase aliases the operation phase object from lib/storage
func (*Phase) AddParallel ¶
AddParallel will append sub-phases which depend on parent only
func (*Phase) AddSequential ¶
AddSequential will append sub-phases which depend one upon another
func (*Phase) AddWithDependency ¶
AddWithDependency sets phase as explicit dependency on subs
func (*Phase) ChildLiteral ¶
ChildLiteral formats sub as a child of this phase and returns the path
func (*Phase) RequireLiteral ¶
RequireLiteral adds the specified phase IDs as requirements for this phase
type PhaseIder ¶
type PhaseIder interface { // GetID identifies the phase by ID GetID() string }
PhaseIder is an interface to identify phases
type PhaseRef ¶
type PhaseRef string
PhaseRef refers to a phase by ID
func DependencyForServer ¶
DependencyForServer looks up a dependency in the list of sub-phases of the give phase that references the specified server and returns a reference to it. If no server has been found, it retruns the reference to the phase itself
type Phases ¶
type Phases []Phase
Phases is a list of Phase
func (Phases) AsPhases ¶
func (r Phases) AsPhases() (result []storage.OperationPhase)
AsPhases converts this list to a slice of storate.OperationPhase
type Reconciler ¶
type Reconciler interface { // ReconcilePlan syncs changes for the specified plan and returns the updated plan ReconcilePlan(context.Context, storage.OperationPlan) (*storage.OperationPlan, error) }
Reconciler can sync plan changes between backends
func NewDefaultReconciler ¶
func NewDefaultReconciler(remote, authoritative storage.Backend, clusterName, operationID string, logger logrus.FieldLogger) Reconciler
NewDefaultReconciler returns an implementation of Reconciler that syncs changes between the authoritative and the remote backends
type Updater ¶
type Updater struct { // Config defines the updater configuration Config // contains filtered or unexported fields }
Updater manages the operation specified with machine
func NewUpdater ¶
NewUpdater returns a new updater for the specified operation using the given machine
func (*Updater) GetPlan ¶
func (r *Updater) GetPlan() (*storage.OperationPlan, error)
GetPlan returns the up-to-date operation plan
func (*Updater) RollbackPhase ¶
func (r *Updater) RollbackPhase(ctx context.Context, params fsm.Params, phaseTimeout time.Duration) error
RollbackPhase rolls back the specified phase.
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
builder
Package builder implements richer support for working with operation phases
|
Package builder implements richer support for working with operation phases |
rollingupdate
This file implements a rolling update FSM
|
This file implements a rolling update FSM |