controller

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2020 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultResyncPeriod is used when option function ResyncPeriod is omitted
	DefaultResyncPeriod = 15 * time.Minute
	// DefaultThreadiness is used when option function Threadiness is omitted
	DefaultThreadiness = 4
	// DefaultExponentialBackOffOnError is used when option function ExponentialBackOffOnError is omitted
	DefaultExponentialBackOffOnError = true
	// DefaultCreateProvisionedBucketRetryCount is used when option function CreateProvisionedBucketRetryCount is omitted
	DefaultCreateProvisionedBucketRetryCount = 5
	// DefaultCreateProvisionedBucketnterval is used when option function CreateProvisionedBucketInterval is omitted
	DefaultCreateProvisionedBucketInterval = 10 * time.Second
	// DefaultFailedProvisionThreshold is used when option function FailedProvisionThreshold is omitted
	DefaultFailedProvisionThreshold = 15
	// DefaultFailedDeleteThreshold is used when option function FailedDeleteThreshold is omitted
	DefaultFailedDeleteThreshold = 15
	// DefaultLeaderElection is used when option function LeaderElection is omitted
	DefaultLeaderElection = true
	// DefaultLeaseDuration is used when option function LeaseDuration is omitted
	DefaultLeaseDuration = 15 * time.Second
	// DefaultRenewDeadline is used when option function RenewDeadline is omitted
	DefaultRenewDeadline = 10 * time.Second
	// DefaultRetryPeriod is used when option function RetryPeriod is omitted
	DefaultRetryPeriod = 2 * time.Second
	// DefaultMetricsPort is used when option function MetricsPort is omitted
	DefaultMetricsPort = 0
	// DefaultMetricsAddress is used when option function MetricsAddress is omitted
	DefaultMetricsAddress = "0.0.0.0"
	// DefaultMetricsPath is used when option function MetricsPath is omitted
	DefaultMetricsPath = "/metrics"
	// DefaultAddFinalizer is used when option function AddFinalizer is omitted
	DefaultAddFinalizer = false
)

Variables

This section is empty.

Functions

func BucketInformer

func BucketInformer(informer cache.SharedInformer) func(*ProvisionController) error

BucketInformer sets the informer to use for accessing Buckets. Defaults to using a internal informer.

func BucketRequestInformer

func BucketRequestInformer(informer cache.SharedIndexInformer) func(*ProvisionController) error

BucketRequestInformer sets the informer to use for accessing BucketRequests. Defaults to using a internal informer.

func ExponentialBackOffOnError

func ExponentialBackOffOnError(exponentialBackOffOnError bool) func(*ProvisionController) error

ExponentialBackOffOnError determines whether to exponentially back off from failures of Provision and Delete. Defaults to true.

func FailedDeleteThreshold

func FailedDeleteThreshold(failedDeleteThreshold int) func(*ProvisionController) error

FailedDeleteThreshold is the threshold for max number of retries on failures of Delete. Set to 0 to retry indefinitely. Defaults to 15.

func FailedProvisionThreshold

func FailedProvisionThreshold(failedProvisionThreshold int) func(*ProvisionController) error

FailedProvisionThreshold is the threshold for max number of retries on failures of Provision. Set to 0 to retry indefinitely. Defaults to 15.

func ProvisionTimeout

func ProvisionTimeout(timeout time.Duration) func(*ProvisionController) error

ProvisionTimeout sets the amount of time that provisioning a bucket may take. The default is unlimited.

func RateLimiter

func RateLimiter(rateLimiter workqueue.RateLimiter) func(*ProvisionController) error

RateLimiter is the workqueue.RateLimiter to use for the provisioning and deleting work queues. If set, ExponentialBackOffOnError is ignored.

func ResyncPeriod

func ResyncPeriod(resyncPeriod time.Duration) func(*ProvisionController) error

ResyncPeriod is how often the controller relists bucketRequests, buckets, & bucket classes. OnUpdate will be called even if nothing has changed, meaning failed operations may be retried on a bucketRequest/bucket every resyncPeriod regardless of whether it changed. Defaults to 15 minutes.

func Threadiness

func Threadiness(threadiness int) func(*ProvisionController) error

Threadiness is the number of bucketRequest and bucket workers each to launch. Defaults to 4.

Types

type BucketStore

type BucketStore interface {
	// StoreBucket makes sure a bucket is saved to Kubernetes API server.
	// If no error is returned, caller can assume that PV was saved or
	// is being saved in background.
	// In error is returned, no PV was saved and corresponding PVC needs
	// to be re-queued (so whole provisioning needs to be done again).
	StoreBucket(bucketRequest *v1alpha1.BucketRequest, bucket *v1alpha1.Bucket) error

	// Runs any background goroutines for implementation of the interface.
	Run(ctx context.Context, threadiness int)
}

BucketStore is an interface that's used to save Buckets to API server. Implementation of the interface add custom error recovery policy. A bucket is added via StoreBucket(). It's enough to store the bucket only once. It is not possible to remove a bucket, even when corresponding PVC is deleted and PV is not necessary any longer. PV will be always created. If corresponding PVC is deleted, the PV will be deleted by Kubernetes using standard deletion procedure. It saves us some code here.

func NewBucketStoreQueue

func NewBucketStoreQueue(
	client kubernetes.Interface,
	limiter workqueue.RateLimiter,
	bucketRequestsIndexer cache.Indexer,
	eventRecorder record.EventRecorder,
) BucketStore

NewBucketStoreQueue returns BucketStore that uses asynchronous workqueue to save PVs.

type IgnoredError

type IgnoredError struct {
	Reason string
}

IgnoredError is the value for Delete to return to indicate that the call has been ignored and no action taken. In case multiple provisioners are serving the same storage class, provisioners may ignore buckets they are not responsible for (e.g. ones they didn't create). The controller will act accordingly, i.e. it won't emit a misleading bucketFailedDelete event.

func (*IgnoredError) Error

func (e *IgnoredError) Error() string

type ProvisionController

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

ProvisionController is a controller that provisions Bucket for BucketRequests.

func NewProvisionController

func NewProvisionController(
	client kubernetes.Interface,
	cosiclient cosiclient.Interface,
	provisionerName string,
	provisioner Provisioner,
	kubeVersion string,
	options ...func(*ProvisionController) error,
) *ProvisionController

NewProvisionController creates a new provision controller using the given configuration parameters and with private (non-shared) informers.

func (*ProvisionController) HasRun

func (ctrl *ProvisionController) HasRun() bool

HasRun returns whether the controller has Run

func (*ProvisionController) Run

func (ctrl *ProvisionController) Run(ctx context.Context)

Run starts all of this controller's control loops

type ProvisionOptions

type ProvisionOptions struct {
	// BucketClass is a reference to the storage class that is used for
	// provisioning for this bucket
	BucketClass *v1alpha1.BucketClass

	// Bucket.Name of the appropriate Bucket. Used to generate cloud
	// bucket name.
	BucketName string

	// bucketRequest is reference to the claim that lead to provisioning of a new bucket.
	// Provisioners *must* create a bucket that would be matched by this bucketRequest,
	// i.e. with required capacity, accessMode, labels matching bucketRequest.Selector and
	// so on.
	BucketRequest *v1alpha1.BucketRequest

	// Node selected by the scheduler for the bucket.
	SelectedNode *v1.Node
}

ProvisionOptions contains all information required to provision a bucket

type Provisioner

type Provisioner interface {
	// Provision creates a bucket i.e. the storage asset and returns a bucket object
	// for the bucket. The provisioner can return an error (e.g. timeout) and state
	// ProvisioningInBackground to tell the controller that provisioning may be in
	// progress after Provision() finishes. The controller will call Provision()
	// again with the same parameters, assuming that the provisioner continues
	// provisioning the bucket. The provisioner must return either final error (with
	// ProvisioningFinished) or success eventually, otherwise the controller will try
	// forever (unless FailedProvisionThreshold is set).
	Provision(context.Context, ProvisionOptions) (*v1alpha1.Bucket, ProvisioningState, error)
}

Provisioner is an interface that creates templates for Buckets and can create the bucket as a new resource in the infrastructure provider. It can also remove the bucket it created from the underlying storage provider.

type ProvisioningState

type ProvisioningState string

ProvisioningState is state of bucket provisioning. It tells the controller if provisioning could be in progress in the background after Provision() call returns or the provisioning is 100% finished (either with success or error).

const (
	// ProvisioningInBackground tells the controller that provisioning may be in
	// progress in background after Provision call finished.
	ProvisioningInBackground ProvisioningState = "Background"
	// ProvisioningFinished tells the controller that provisioning for sure does
	// not continue in background, error code of Provision() is final.
	ProvisioningFinished ProvisioningState = "Finished"
	// ProvisioningNoChange tells the controller that provisioning state is the same as
	// before the call - either ProvisioningInBackground or ProvisioningFinished from
	// the previous Provision(). This state is typically returned by a provisioner
	// before it could reach storage backend - the provisioner could not check status
	// of provisioning and previous state applies. If this state is returned from the
	// first Provision call, ProvisioningFinished is assumed (the provisioning
	// could not even start).
	ProvisioningNoChange ProvisioningState = "NoChange"
	// ProvisioningReschedule tells the controller that it shall stop all further
	// attempts to provision the bucket and instead ask the Kubernetes scheduler
	// to pick a different node. This only makes sense for buckets with a selected
	// node, i.e. those with late binding, and must only be returned when it is certain
	// that provisioning does not continue in the background. The error returned together
	// with this state contains further information why rescheduling is needed.
	ProvisioningReschedule ProvisioningState = "Reschedule"
)

type Qualifier

type Qualifier interface {
	// ShouldProvision returns whether provisioning for the claim should
	// be attempted.
	ShouldProvision(context.Context, *v1alpha1.BucketRequest) bool
}

Qualifier is an optional interface implemented by provisioners to determine whether a claim should be provisioned as early as possible (e.g. prior to leader election).

Jump to

Keyboard shortcuts

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