v1.12.1 Latest Latest

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

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 46 Imported by: 1




View Source
const (
	// CSPCLeaseKey is the key that will be used to acquire lease on cspc object.
	// It will be present in cspc annotations.
	// If key has an empty value, that means no one has acquired a lease on cspc object.
	CSPCLeaseKey = ""
	// PatchOperation is the strategy of patch operation.
	PatchOperation = "replace"
	// PatchPath is the path to the field on cspc object which need to be patched.
	PatchPath = "/metadata/annotations/"
View Source
const (
	OpenEBSServiceAccount = "openebs-maya-operator"
	// PoolMgmtContainerName is the name of cstor target container name
	PoolMgmtContainerName = "cstor-pool-mgmt"

	// PoolContainerName is the name of cstor target container name
	PoolContainerName = "cstor-pool"

	// PoolExporterContainerName is the name of cstor target container name
	PoolExporterContainerName = "maya-exporter"

OpenEBSServiceAccount name of the openebs service accout with required permissions

View Source
const (
	// ResyncInterval is sync interval of the watcher
	ResyncInterval = 30 * time.Second


This section is empty.


func Start

func Start() error

Start starts the cstor-operator.


type Controller

type Controller struct {
	// contains filtered or unexported fields

Controller is the controller implementation for CSPC resources

func (*Controller) EstimateCSPCVersion

func (c *Controller) EstimateCSPCVersion(cspc *apis.CStorPoolCluster) (string, error)

EstimateCSPCVersion returns the cspi version if any cspi is present for the cspc or returns the maya version as the new cspi created will be of maya version

func (*Controller) NewPoolConfig

func (c *Controller) NewPoolConfig(cspc *apis.CStorPoolCluster, namespace string) (*PoolConfig, error)

NewPoolConfig returns a poolconfig object

func (*Controller) Run

func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error

Run will set up the event handlers for types we are interested in, as well as syncing informer caches and starting workers. It will block until stopCh is closed, at which point it will shutdown the workqueue and wait for workers to finish processing their current work items.

type ControllerBuilder

type ControllerBuilder struct {
	Controller *Controller

ControllerBuilder is the builder object for controller.

func NewControllerBuilder

func NewControllerBuilder() *ControllerBuilder

NewControllerBuilder returns an empty instance of controller builder.

func (*ControllerBuilder) Build

func (cb *ControllerBuilder) Build() (*Controller, error)

Build returns a controller instance.

type Lease

type Lease struct {
	// Object is the object over which lease is to be taken
	Object interface{}
	// contains filtered or unexported fields

Lease is the struct which will implement the Leases interface

func (*Lease) Hold

func (sl *Lease) Hold() error

Hold is the implenetation of method from interface Leases It will try to hold a lease on cspc object.

func (*Lease) Release

func (sl *Lease) Release()

Release method is implementation of to release lease on a given cspc.

func (*Lease) Update

func (sl *Lease) Update(podName string) error

Update will update a lease on cspc depending on type of update that is required. We have following type of update strategy: 1.putKeyValue 2.putValue 3.putUpdatedValue See the functions(below) for more details on update strategy

type LeaseContract

type LeaseContract struct {
	// Holder is the namespace/name of the pod who acquires the lease
	Holder string `json:"holder"`
	// LeaderTransition is the count of lease that has been taken on the object
	// in its lifetime.
	// e.g. One of the pod takes a lease on the object and release and then some other
	// pod (or even the same pod ) takes a lease again on the object its leaderTransition
	// value is 1.
	// If an object has leaderTranisiton value equal to 'n' that means it was leased
	// 'n+1' times in its lifetime by distinct, same or some distinct and some same pods.
	LeaderTransition int `json:"leaderTransition"`

LeaseContract struct will be used as a value of lease key that will give information about an acquired lease on object The struct object will be parsed to string which will be then put as a value to the lease key of object annotation.

type Leaser

type Leaser interface {
	// Hold will try to get a lease, in case of failure it will return error
	Hold() error
	// Update will update the lease value on the object
	Update(leaseValue string) error
	// Release will remove the acquired lease on the object

Leaser is an interface which assists in getting and releasing lease on an object

type Patch

type Patch struct {
	// Op defines the operation
	Op string `json:"op"`
	// Path defines the key path
	// eg. for
	// {
	//  	"Name": "openebs"
	//	    Category: {
	//		  "Inclusive": "v1",
	//		  "Rank": "A"
	//	     }
	// }
	// The path of 'Inclusive' would be
	// "/Name/Category/Inclusive"
	Path  string `json:"path"`
	Value string `json:"value"`

Patch struct will used to patch the cspc object by a lease holder to release the lease once done.

type PoolConfig

type PoolConfig struct {
	AlgorithmConfig *nodeselect.Config
	Controller      *Controller

PoolConfig embeds nodeselect config from algorithm package and Controller object.

func (*PoolConfig) ClaimBD

func (pc *PoolConfig) ClaimBD(bdName string) error

ClaimBD calims a block device

func (*PoolConfig) ClaimBDList

func (pc *PoolConfig) ClaimBDList(bdList []string)

ClaimBDList claims a list of block device

func (*PoolConfig) CreateStoragePool

func (pc *PoolConfig) CreateStoragePool() error

CreateStoragePool creates the required resource to provision a cStor pool

func (*PoolConfig) DownScalePool

func (pc *PoolConfig) DownScalePool() error

DownScalePool deletes the required pool.

func (*PoolConfig) GetPoolDeploySpec

func (pc *PoolConfig) GetPoolDeploySpec(cspi *apis.CStorPoolInstance) (*appsv1.Deployment, error)

GetPoolDeploySpec returns the pool deployment spec.

Jump to

Keyboard shortcuts

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