cvo

package
v0.0.0-...-a45fa12 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2019 License: Apache-2.0 Imports: 70 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ClusterStatusFailing is set on the ClusterVersion status when a cluster
	// cannot reach the desired state. It is considered more serious than Degraded
	// and indicates the cluster is not healthy.
	ClusterStatusFailing = configv1.ClusterStatusConditionType("Failing")
)
View Source
const ClusterVersionInvalid configv1.ClusterStatusConditionType = "Invalid"

ClusterVersionInvalid indicates that the cluster version has an error that prevents the server from taking action. The cluster version operator will only reconcile the current state as long as this condition is set.

Variables

This section is empty.

Functions

func NewResourceBuilder

func NewResourceBuilder(config, burstConfig *rest.Config, clusterOperators configlistersv1.ClusterOperatorLister) payload.ResourceBuilder

NewResourceBuilder creates the default resource builder implementation.

Types

type ConfigSyncWorker

type ConfigSyncWorker interface {
	Start(ctx context.Context, maxWorkers int)
	Update(generation int64, desired configv1.Update, overrides []configv1.ComponentOverride, state payload.State) *SyncWorkerStatus
	StatusCh() <-chan SyncWorkerStatus
}

ConfigSyncWorker abstracts how the image is synchronized to the server. Introduced for testing.

type Operator

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

Operator defines cluster version operator. The CVO attempts to reconcile the appropriate image onto the cluster, writing status to the ClusterVersion object as it goes. A background loop periodically checks for new updates from a server described by spec.upstream and spec.channel. The main CVO sync loop is the single writer of ClusterVersion status.

The CVO updates multiple conditions, but synthesizes them into a summary message on the Progressing condition to answer the question of "what version is available on the cluster". When errors occur, the Failing condition of the status is updated with a detailed message and reason, and then the reason is used to summarize the error onto the Progressing condition's message for a simple overview.

The CVO periodically syncs the whole image to the cluster even if no version transition is detected in order to undo accidental actions.

A release image is expected to contain a CVO binary, the manifests necessary to update the CVO, and the manifests of the other operators on the cluster. During an update the operator attempts to copy the contents of the image manifests into a temporary directory using a batch job and a shared host-path, then applies the CVO manifests using the image image for the CVO deployment. The deployment is then expected to launch the new process, and the new operator picks up the lease and applies the rest of the image.

func New

func New(
	nodename string,
	namespace, name string,
	releaseImage string,
	enableDefaultClusterVersion bool,
	overridePayloadDir string,
	minimumInterval time.Duration,
	cvInformer configinformersv1.ClusterVersionInformer,
	coInformer configinformersv1.ClusterOperatorInformer,
	cmConfigInformer informerscorev1.ConfigMapInformer,
	proxyInformer configinformersv1.ProxyInformer,
	client clientset.Interface,
	kubeClient kubernetes.Interface,
	enableMetrics bool,
	exclude string,
) *Operator

New returns a new cluster version operator.

func (*Operator) HTTPClient

func (optr *Operator) HTTPClient() (*http.Client, error)

HTTPClient provides a method for generating an HTTP client with the proxy and trust settings, if set in the cluster.

func (*Operator) InitializeFromPayload

func (optr *Operator) InitializeFromPayload(restConfig *rest.Config, burstRestConfig *rest.Config) error

InitializeFromPayload retrieves the payload contents and verifies the initial state, then configures the controller that loads and applies content to the cluster. It returns an error if the payload appears to be in error rather than continuing.

func (*Operator) Run

func (optr *Operator) Run(ctx context.Context, workers int)

Run runs the cluster version operator until stopCh is completed. Workers is ignored for now.

func (*Operator) SetSyncWorkerForTesting

func (optr *Operator) SetSyncWorkerForTesting(worker ConfigSyncWorker)

SetSyncWorkerForTesting updates the sync worker for whitebox testing.

type PayloadInfo

type PayloadInfo struct {
	// Directory is the path on disk where the payload is rooted.
	Directory string
	// Local is true if the payload was the payload associated with the operator image.
	Local bool

	// Verified is true if the payload was explicitly verified against the root of trust.
	// If unset and VerificationFailure is nil, the payload should be considered to not have
	// had verification attempted.
	Verified bool
	// VerificationFailure is any error returned by attempting to verify the payload.
	VerificationError error
}

PayloadInfo returns details about the payload when it was retrieved.

type PayloadRetriever

type PayloadRetriever interface {
	// RetrievePayload attempts to retrieve the desired payload, returning info about the payload
	// or an error.
	RetrievePayload(ctx context.Context, desired configv1.Update) (PayloadInfo, error)
}

PayloadRetriever abstracts how a desired version is extracted to disk. Introduced for testing.

type StatusReporter

type StatusReporter interface {
	Report(status SyncWorkerStatus)
}

StatusReporter abstracts how status is reported by the worker run method. Introduced for testing.

type SyncWork

type SyncWork struct {
	Generation int64
	Desired    configv1.Update
	Overrides  []configv1.ComponentOverride
	State      payload.State

	// Completed is the number of times in a row we have synced this payload
	Completed int
	// Attempt is incremented each time we attempt to sync a payload and reset
	// when we change Generation/Desired.
	Attempt int
}

SyncWork represents the work that should be done in a sync iteration.

func (SyncWork) Empty

func (w SyncWork) Empty() bool

Empty returns true if the image is empty for this work.

type SyncWorker

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

SyncWorker retrieves and applies the desired image, tracking the status for the parent to monitor. The worker accepts a desired state via Update() and works to keep that state in sync. Once a particular image version is synced, it will be updated no more often than minimumReconcileInterval.

State transitions:

Initial: wait for valid Update(), report empty status
  Update() -> Sync
Sync: attempt to invoke the syncOnce() method
  syncOnce() returns an error -> Error
  syncOnce() returns nil -> Reconciling
Reconciling: invoke syncOnce() no more often than reconcileInterval
  Update() with different values -> Sync
  syncOnce() returns an error -> Error
  syncOnce() returns nil -> Reconciling
Error: backoff until we are attempting every reconcileInterval
  syncOnce() returns an error -> Error
  syncOnce() returns nil -> Reconciling

func NewSyncWorker

func NewSyncWorker(retriever PayloadRetriever, builder payload.ResourceBuilder, reconcileInterval time.Duration, backoff wait.Backoff, exclude string) *SyncWorker

NewSyncWorker initializes a ConfigSyncWorker that will retrieve payloads to disk, apply them via builder to a server, and obey limits about how often to reconcile or retry on errors.

func NewSyncWorkerWithPreconditions

func NewSyncWorkerWithPreconditions(retriever PayloadRetriever, builder payload.ResourceBuilder, preconditions precondition.List, reconcileInterval time.Duration, backoff wait.Backoff, exclude string) *SyncWorker

NewSyncWorkerWithPreconditions initializes a ConfigSyncWorker that will retrieve payloads to disk, apply them via builder to a server, and obey limits about how often to reconcile or retry on errors. It allows providing preconditions for loading payload.

func (*SyncWorker) Desired

func (w *SyncWorker) Desired() configv1.Update

Desired returns the state the SyncWorker is trying to achieve.

func (*SyncWorker) Start

func (w *SyncWorker) Start(ctx context.Context, maxWorkers int)

Start periodically invokes run, detecting whether content has changed. It is edge-triggered when Update() is invoked and level-driven after the syncOnce() has succeeded for a given input (we are said to be "reconciling").

func (*SyncWorker) Status

func (w *SyncWorker) Status() *SyncWorkerStatus

Status returns a copy of the current worker status.

func (*SyncWorker) StatusCh

func (w *SyncWorker) StatusCh() <-chan SyncWorkerStatus

StatusCh returns a channel that reports status from the worker. The channel is buffered and events can be lost, so this is best used as a trigger to read the latest status.

func (*SyncWorker) Update

func (w *SyncWorker) Update(generation int64, desired configv1.Update, overrides []configv1.ComponentOverride, state payload.State) *SyncWorkerStatus

Update instructs the sync worker to start synchronizing the desired update. The reconciling boolean is ignored unless this is the first time that Update has been called. The returned status represents either the initial state or whatever the last recorded status was. TODO: in the future it may be desirable for changes that alter desired to wait briefly before returning,

giving the sync loop the opportunity to observe our change and begin working towards it.

type SyncWorkerStatus

type SyncWorkerStatus struct {
	Generation int64

	Step    string
	Failure error

	Fraction float32

	Completed   int
	Reconciling bool
	Initial     bool
	VersionHash string

	LastProgress time.Time

	Actual   configv1.Update
	Verified bool
}

SyncWorkerStatus is the status of the sync worker at a given time.

func (SyncWorkerStatus) DeepCopy

func (w SyncWorkerStatus) DeepCopy() *SyncWorkerStatus

DeepCopy copies the worker status.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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