lease

package
v0.0.0-...-a88c85e Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CspLeaseKey is the key that will be used to acquire lease on csp object.
	// It will be present in csp annotations.
	// If key has an empty value, that means no one has acquired a lease on csp object.
	//TODO : Evaluate if openebs.io/lease be a better label.
	CspLeaseKey = "openebs.io/csp-lease"
	// PatchOperation is the strategy of patch operation.
	PatchOperation = "replace"
	// PatchPath is the path to the field on csp object which need to be patched.
	PatchPath = "/metadata/annotations/openebs.io~1csp-lease"
	// PodName is the name of the pool pod.
	PodName = "POD_NAME"
	// NameSpace is the namespace where pool pod is running.
	NameSpace = "NAMESPACE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Lease

type Lease struct {
	// Object is the object over which lease is to be taken
	Object interface{}
	// leaseKey is lease key on object
	LeaseKey string
	// oecs is the openebs clientset
	Oecs clientset.Interface
	// kubeclientset is a standard kubernetes clientset
	Kubeclientset kubernetes.Interface
}

Lease is the struct which will implement the Leases interface

func (*Lease) Hold

func (sl *Lease) Hold() (interface{}, error)

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

func (*Lease) Patch

func (sl *Lease) Patch(name string, nameSpace string, patchType types.PatchType, patches []byte) (*apis.CStorPool, error)

Patch is the specific implementation if Patch() interface for patching CSP objects. Similarly, we can have for other objects, if required.

func (*Lease) Release

func (sl *Lease) Release()

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

func (*Lease) Update

func (sl *Lease) Update(podName string) (interface{}, error)

Update will update a lease on csp 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() (interface{}, error)
	// Update will update the lease value on the object
	Update(leaseValue string) (interface{}, error)
	// Release will remove the acquired lease on the object
	Release()
}

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

Jump to

Keyboard shortcuts

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