controller

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FailedCreateInstanceReason is added in an event and in a replica set condition
	// when a instance for a replica set is failed to be created.
	FailedCreateInstanceReason = "FailedCreate"
	// SuccessfulCreateInstanceReason is added in an event when a instance for a replica set
	// is successfully created.
	SuccessfulCreateInstanceReason = "SuccessfulCreate"
	// FailedDeleteInstanceReason is added in an event and in a replica set condition
	// when a instance for a replica set is failed to be deleted.
	FailedDeleteInstanceReason = "FailedDelete"
	// SuccessfulDeleteInstanceReason is added in an event when a instance for a replica set
	// is successfully deleted.
	SuccessfulDeleteInstanceReason = "SuccessfulDelete"
)

Reasons for instance events

Variables

View Source
var (
	CSRToken = cluster.AnnotationPrefix + "csr"
)

Functions

func FilterActiveInstances

func FilterActiveInstances(instances []*cluster.Instance) []*cluster.Instance

FilterActiveInstances returns instances that have not terminated.

func GetInstanceFromTemplate

func GetInstanceFromTemplate(template *cluster.InstanceTemplateSpec, parentObject runtime.Object, controllerRef *metav1.OwnerReference) (*cluster.Instance, error)

func GetSecretsFromTemplate

func GetSecretsFromTemplate(template *cluster.InstanceTemplateSpec, parentObject runtime.Object, controllerRef *metav1.OwnerReference) ([]v1.Secret, error)

func InstanceKey

func InstanceKey(instance *cluster.Instance) string

func IsInstanceActive

func IsInstanceActive(p *cluster.Instance) bool

Types

type ActiveInstances

type ActiveInstances []*cluster.Instance

ActiveInstances type allows custom sorting of instances so a controller can pick the best ones to delete.

func (ActiveInstances) Len

func (s ActiveInstances) Len() int

func (ActiveInstances) Less

func (s ActiveInstances) Less(i, j int) bool

func (ActiveInstances) Swap

func (s ActiveInstances) Swap(i, j int)

type InstanceControlInterface

type InstanceControlInterface interface {
	// CreateInstances creates new instances according to the spec.
	CreateInstances(namespace string, template *cluster.InstanceTemplateSpec, object runtime.Object) error
	// CreateInstancesOnNode creates a new instance according to the spec on the specified node.
	CreateInstancesOnNode(nodeName, namespace string, template *cluster.InstanceTemplateSpec, object runtime.Object) error
	// CreateInstancesWithControllerRef creates new instances according to the spec, and sets object as the instance's controller.
	CreateInstancesWithControllerRef(namespace string, template *cluster.InstanceTemplateSpec, object runtime.Object, controllerRef *metav1.OwnerReference) error
	// DeleteInstance deletes the instance identified by instanceID.
	DeleteInstance(namespace string, instanceID string, object runtime.Object) error
	// PatchInstance patches the instance.
	PatchInstance(namespace, name string, data []byte) error
	// Unbind
	UnbindInstanceWithReservedInstance(instance *cluster.Instance) error
	BindReservedInstance(ri *cluster.ReservedInstance, instance *cluster.Instance, unbind bool) (updatedRI *cluster.ReservedInstance, err error)
}

InstanceControlInterface is an interface that knows how to add or delete instances created as an interface to allow testing.

type InstanceControllerRefManager

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

func NewInstanceControllerRefManager

func NewInstanceControllerRefManager(
	instanceControl InstanceControlInterface,
	controllerObject metav1.ObjectMeta,
	controllerSelector labels.Selector,
	controllerKind schema.GroupVersionKind,
) *InstanceControllerRefManager

NewInstanceControllerRefManager returns a InstanceControllerRefManager that exposes methods to manage the controllerRef of instances.

func (*InstanceControllerRefManager) AdoptInstance

func (m *InstanceControllerRefManager) AdoptInstance(instance *cluster.Instance) error

AdoptInstance sends a patch to take control of the instance. It returns the error if the patching fails.

func (*InstanceControllerRefManager) Classify

func (m *InstanceControllerRefManager) Classify(instances []*cluster.Instance) (
	matchesAndControlled []*cluster.Instance,
	matchesNeedsController []*cluster.Instance,
	controlledDoesNotMatch []*cluster.Instance)

Classify first filters out inactive instances, then it classify the remaining instances into three categories: 1. matchesAndControlled are the instances whose labels match the selector of the RC, and have a controllerRef pointing to the controller 2. matchesNeedsController are the instances whose labels match the RC, but don't have a controllerRef. (Instances with matching labels but with a controllerRef pointing to other object are ignored) 3. controlledDoesNotMatch are the instances that have a controllerRef pointing to the controller, but their labels no longer match the selector.

func (*InstanceControllerRefManager) ReleaseInstance

func (m *InstanceControllerRefManager) ReleaseInstance(instance *cluster.Instance) error

ReleaseInstance sends a patch to free the instance from the control of the controller. It returns the error if the patching fails. 404 and 422 errors are ignored.

type RealInstanceControl

type RealInstanceControl struct {
	KubeClient clientset.Interface
	Recorder   record.EventRecorder
}

RealInstanceControl is the default implementation of InstanceControlInterface.

func (RealInstanceControl) BindReservedInstance added in v0.3.0

func (r RealInstanceControl) BindReservedInstance(ri *cluster.ReservedInstance, instance *cluster.Instance, unbind bool) (updatedRI *cluster.ReservedInstance, err error)

Update both reserved instance and instance. Get related reserved instance if not provided. Update only instance if no reserved instance provided or found

func (RealInstanceControl) CreateInstances

func (r RealInstanceControl) CreateInstances(namespace string, template *cluster.InstanceTemplateSpec, object runtime.Object) error

func (RealInstanceControl) CreateInstancesOnNode

func (r RealInstanceControl) CreateInstancesOnNode(nodeName, namespace string, template *cluster.InstanceTemplateSpec, object runtime.Object) error

func (RealInstanceControl) CreateInstancesWithControllerRef

func (r RealInstanceControl) CreateInstancesWithControllerRef(namespace string, template *cluster.InstanceTemplateSpec, controllerObject runtime.Object, controllerRef *metav1.OwnerReference) error

func (RealInstanceControl) DeleteInstance

func (r RealInstanceControl) DeleteInstance(namespace string, instanceID string, object runtime.Object) error

func (RealInstanceControl) PatchInstance

func (r RealInstanceControl) PatchInstance(namespace, name string, data []byte) error

func (RealInstanceControl) UnbindInstanceWithReservedInstance added in v0.3.0

func (r RealInstanceControl) UnbindInstanceWithReservedInstance(instance *cluster.Instance) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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