controller

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2020 License: Apache-2.0 Imports: 33 Imported by: 23

Documentation

Index

Constants

View Source
const (
	// https://github.com/pingcap/tidb/blob/master/owner/manager.go#L183
	// NotDDLOwnerError is the error message which was returned when the tidb node is not a ddl owner
	NotDDLOwnerError = "This node is not a ddl owner, can't be resigned."
)

Variables

View Source
var (

	// DefaultStorageClassName is the default storageClassName
	DefaultStorageClassName string
	// ClusterScoped controls whether operator should manage kubernetes cluster wide TiDB clusters
	ClusterScoped bool
	// TestMode defines whether tidb operator run in test mode, test mode is only open when test
	TestMode bool
	// ResyncDuration is the resync time of informer
	ResyncDuration time.Duration
)
View Source
var (
	TestStoreID       string = "000"
	TestMemberID      string = "111"
	TestClusterID     string = "222"
	TestName          string = "tidb-cluster"
	TestComponentName string = "tikv"
	TestPodName       string = "pod-1"
	TestManagedByName string = "tidb-operator"
	TestClusterName   string = "test"
)
View Source
var ExternalTrafficPolicy string

ExternalTrafficPolicy denotes if this Service desires to route external traffic to node-local or cluster-wide endpoints.

Functions

func AnnProm

func AnnProm(port int32) map[string]string

AnnProm adds annotations for prometheus scraping metrics

func GetOwnerRef

func GetOwnerRef(tc *v1alpha1.TidbCluster) metav1.OwnerReference

GetOwnerRef returns TidbCluster's OwnerReference

func GetPDClient added in v1.0.0

func GetPDClient(pdControl pdapi.PDControlInterface, tc *v1alpha1.TidbCluster) pdapi.PDClient

GetPDClient gets the pd client from the TidbCluster

func GetServiceType

func GetServiceType(services []v1alpha1.Service, serviceName string) corev1.ServiceType

GetServiceType returns member's service type

func GetSlowLogTailerImage added in v1.0.0

func GetSlowLogTailerImage(cluster *v1alpha1.TidbCluster) string

func Int32Ptr added in v1.0.2

func Int32Ptr(i int32) *int32

Int32Ptr returns a pointer to an int32

func IsRequeueError added in v0.2.1

func IsRequeueError(err error) bool

IsRequeueError returns whether err is a RequeueError

func MemberConfigMapName added in v1.0.0

func MemberConfigMapName(tc *v1alpha1.TidbCluster, member v1alpha1.MemberType) string

MemberConfigMapName returns the default ConfigMap name of the specified member type

func NewFakePDClient

func NewFakePDClient(pdControl *pdapi.FakePDControl, tc *v1alpha1.TidbCluster) *pdapi.FakePDClient

NewFakePDClient creates a fake pdclient that is set as the pd client

func PDMemberName

func PDMemberName(clusterName string) string

PDMemberName returns pd member name

func PDPeerMemberName

func PDPeerMemberName(clusterName string) string

PDPeerMemberName returns pd peer service name

func RequeueErrorf added in v0.2.1

func RequeueErrorf(format string, a ...interface{}) error

RequeueErrorf returns a RequeueError

func TiDBMemberName

func TiDBMemberName(clusterName string) string

TiDBMemberName returns tidb member name

func TiDBPeerMemberName added in v0.2.0

func TiDBPeerMemberName(clusterName string) string

TiDBPeerMemberName returns tidb peer service name

func TiKVCapacity

func TiKVCapacity(limits *v1alpha1.ResourceRequirement) string

TiKVCapacity returns string resource requirement, tikv uses GB, TB as unit suffix, but it actually means GiB, TiB

func TiKVMemberName

func TiKVMemberName(clusterName string) string

TiKVMemberName returns tikv member name

func TiKVPeerMemberName

func TiKVPeerMemberName(clusterName string) string

TiKVPeerMemberName returns tikv peer service name

Types

type FakePVCControl

type FakePVCControl struct {
	PVCIndexer cache.Indexer
	// contains filtered or unexported fields
}

FakePVCControl is a fake PVCControlInterface

func NewFakePVCControl

func NewFakePVCControl(pvcInformer coreinformers.PersistentVolumeClaimInformer) *FakePVCControl

NewFakePVCControl returns a FakePVCControl

func (*FakePVCControl) DeletePVC

DeletePVC deletes the pvc

func (*FakePVCControl) SetDeletePVCError

func (fpc *FakePVCControl) SetDeletePVCError(err error, after int)

SetDeletePVCError sets the error attributes of deletePVCTracker

func (*FakePVCControl) SetUpdatePVCError

func (fpc *FakePVCControl) SetUpdatePVCError(err error, after int)

SetUpdatePVCError sets the error attributes of updatePVCTracker

func (*FakePVCControl) UpdateMetaInfo

UpdateMetaInfo updates the meta info of pvc

func (*FakePVCControl) UpdatePVC

UpdatePVC updates the annotation, labels and spec of pvc

type FakePVControl

type FakePVControl struct {
	PVCLister corelisters.PersistentVolumeClaimLister
	PVIndexer cache.Indexer
	// contains filtered or unexported fields
}

FakePVControl is a fake PVControlInterface

func NewFakePVControl

NewFakePVControl returns a FakePVControl

func (*FakePVControl) PatchPVReclaimPolicy

func (fpc *FakePVControl) PatchPVReclaimPolicy(_ *v1alpha1.TidbCluster, pv *corev1.PersistentVolume, reclaimPolicy corev1.PersistentVolumeReclaimPolicy) error

PatchPVReclaimPolicy patchs the reclaim policy of PV

func (*FakePVControl) SetUpdatePVError

func (fpc *FakePVControl) SetUpdatePVError(err error, after int)

SetUpdatePVError sets the error attributes of updatePVTracker

func (*FakePVControl) UpdateMetaInfo

UpdateMetaInfo update the meta info of pv

type FakePodControl

type FakePodControl struct {
	PodIndexer cache.Indexer
	// contains filtered or unexported fields
}

FakePodControl is a fake PodControlInterface

func NewFakePodControl

func NewFakePodControl(podInformer coreinformers.PodInformer) *FakePodControl

NewFakePodControl returns a FakePodControl

func (*FakePodControl) DeletePod added in v0.2.0

func (fpc *FakePodControl) DeletePod(_ *v1alpha1.TidbCluster, pod *corev1.Pod) error

func (*FakePodControl) SetDeletePodError added in v0.2.0

func (fpc *FakePodControl) SetDeletePodError(err error, after int)

SetDeletePodError sets the error attributes of deletePodTracker

func (*FakePodControl) SetGetClusterError

func (fpc *FakePodControl) SetGetClusterError(err error, after int)

SetGetClusterError sets the error attributes of getClusterTracker

func (*FakePodControl) SetGetMemberError

func (fpc *FakePodControl) SetGetMemberError(err error, after int)

SetGetMemberError sets the error attributes of getMemberTracker

func (*FakePodControl) SetGetStoreError

func (fpc *FakePodControl) SetGetStoreError(err error, after int)

SetGetStoreError sets the error attributes of getStoreTracker

func (*FakePodControl) SetUpdatePodError

func (fpc *FakePodControl) SetUpdatePodError(err error, after int)

SetUpdatePodError sets the error attributes of updatePodTracker

func (*FakePodControl) UpdateMetaInfo

func (fpc *FakePodControl) UpdateMetaInfo(_ *v1alpha1.TidbCluster, pod *corev1.Pod) (*corev1.Pod, error)

UpdateMetaInfo update the meta info of Pod

func (*FakePodControl) UpdatePod added in v0.2.0

func (fpc *FakePodControl) UpdatePod(_ *v1alpha1.TidbCluster, pod *corev1.Pod) (*corev1.Pod, error)

type FakeServiceControl

type FakeServiceControl struct {
	SvcLister  corelisters.ServiceLister
	SvcIndexer cache.Indexer
	EpsIndexer cache.Indexer
	TcLister   v1listers.TidbClusterLister
	TcIndexer  cache.Indexer
	// contains filtered or unexported fields
}

FakeServiceControl is a fake ServiceControlInterface

func NewFakeServiceControl

func NewFakeServiceControl(svcInformer coreinformers.ServiceInformer, epsInformer coreinformers.EndpointsInformer, tcInformer tcinformers.TidbClusterInformer) *FakeServiceControl

NewFakeServiceControl returns a FakeServiceControl

func (*FakeServiceControl) CreateService

func (ssc *FakeServiceControl) CreateService(_ *v1alpha1.TidbCluster, svc *corev1.Service) error

CreateService adds the service to SvcIndexer

func (*FakeServiceControl) DeleteService

func (ssc *FakeServiceControl) DeleteService(_ *v1alpha1.TidbCluster, _ *corev1.Service) error

DeleteService deletes the service of SvcIndexer

func (*FakeServiceControl) SetCreateServiceError

func (ssc *FakeServiceControl) SetCreateServiceError(err error, after int)

SetCreateServiceError sets the error attributes of createServiceTracker

func (*FakeServiceControl) SetDeleteServiceError

func (ssc *FakeServiceControl) SetDeleteServiceError(err error, after int)

SetDeleteServiceError sets the error attributes of deleteServiceTracker

func (*FakeServiceControl) SetUpdateServiceError

func (ssc *FakeServiceControl) SetUpdateServiceError(err error, after int)

SetUpdateServiceError sets the error attributes of updateServiceTracker

func (*FakeServiceControl) UpdateService

func (ssc *FakeServiceControl) UpdateService(_ *v1alpha1.TidbCluster, svc *corev1.Service) (*corev1.Service, error)

UpdateService updates the service of SvcIndexer

type FakeStatefulSetControl

type FakeStatefulSetControl struct {
	SetLister  appslisters.StatefulSetLister
	SetIndexer cache.Indexer
	TcLister   v1listers.TidbClusterLister
	TcIndexer  cache.Indexer
	// contains filtered or unexported fields
}

FakeStatefulSetControl is a fake StatefulSetControlInterface

func NewFakeStatefulSetControl

func NewFakeStatefulSetControl(setInformer appsinformers.StatefulSetInformer, tcInformer tcinformers.TidbClusterInformer) *FakeStatefulSetControl

NewFakeStatefulSetControl returns a FakeStatefulSetControl

func (*FakeStatefulSetControl) CreateStatefulSet

func (ssc *FakeStatefulSetControl) CreateStatefulSet(_ *v1alpha1.TidbCluster, set *apps.StatefulSet) error

CreateStatefulSet adds the statefulset to SetIndexer

func (*FakeStatefulSetControl) DeleteStatefulSet

func (ssc *FakeStatefulSetControl) DeleteStatefulSet(_ *v1alpha1.TidbCluster, _ *apps.StatefulSet) error

DeleteStatefulSet deletes the statefulset of SetIndexer

func (*FakeStatefulSetControl) SetCreateStatefulSetError

func (ssc *FakeStatefulSetControl) SetCreateStatefulSetError(err error, after int)

SetCreateStatefulSetError sets the error attributes of createStatefulSetTracker

func (*FakeStatefulSetControl) SetDeleteStatefulSetError

func (ssc *FakeStatefulSetControl) SetDeleteStatefulSetError(err error, after int)

SetDeleteStatefulSetError sets the error attributes of deleteStatefulSetTracker

func (*FakeStatefulSetControl) SetStatusChange

func (ssc *FakeStatefulSetControl) SetStatusChange(fn func(*apps.StatefulSet))

func (*FakeStatefulSetControl) SetUpdateStatefulSetError

func (ssc *FakeStatefulSetControl) SetUpdateStatefulSetError(err error, after int)

SetUpdateStatefulSetError sets the error attributes of updateStatefulSetTracker

func (*FakeStatefulSetControl) UpdateStatefulSet

func (ssc *FakeStatefulSetControl) UpdateStatefulSet(_ *v1alpha1.TidbCluster, set *apps.StatefulSet) (*apps.StatefulSet, error)

UpdateStatefulSet updates the statefulset of SetIndexer

type FakeTiDBControl added in v0.2.0

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

FakeTiDBControl is a fake implementation of TiDBControlInterface.

func NewFakeTiDBControl added in v0.2.0

func NewFakeTiDBControl() *FakeTiDBControl

NewFakeTiDBControl returns a FakeTiDBControl instance

func (*FakeTiDBControl) GetHealth added in v0.2.0

func (ftd *FakeTiDBControl) GetHealth(_ *v1alpha1.TidbCluster) map[string]bool

func (*FakeTiDBControl) GetInfo added in v1.0.0

func (ftd *FakeTiDBControl) GetInfo(tc *v1alpha1.TidbCluster, ordinal int32) (*dbInfo, error)

func (*FakeTiDBControl) GetSettings added in v1.0.0

func (ftd *FakeTiDBControl) GetSettings(tc *v1alpha1.TidbCluster, ordinal int32) (*config.Config, error)

func (*FakeTiDBControl) NotDDLOwner added in v0.3.0

func (ftd *FakeTiDBControl) NotDDLOwner(notDDLOwner bool)

NotDDLOwner sets whether the tidb is the ddl owner

func (*FakeTiDBControl) ResignDDLOwner added in v0.3.0

func (ftd *FakeTiDBControl) ResignDDLOwner(tc *v1alpha1.TidbCluster, ordinal int32) (bool, error)

func (*FakeTiDBControl) SetHealth added in v0.2.0

func (ftd *FakeTiDBControl) SetHealth(healthInfo map[string]bool)

SetHealth set health info for FakeTiDBControl

func (*FakeTiDBControl) SetResignDDLOwnerError added in v0.3.0

func (ftd *FakeTiDBControl) SetResignDDLOwnerError(err error)

SetResignDDLOwner sets error of resign ddl owner for FakeTiDBControl

type FakeTidbClusterControl added in v0.2.0

type FakeTidbClusterControl struct {
	TcLister  listers.TidbClusterLister
	TcIndexer cache.Indexer
	// contains filtered or unexported fields
}

FakeTidbClusterControl is a fake TidbClusterControlInterface

func NewFakeTidbClusterControl added in v0.2.0

func NewFakeTidbClusterControl(tcInformer tcinformers.TidbClusterInformer) *FakeTidbClusterControl

NewFakeTidbClusterControl returns a FakeTidbClusterControl

func (*FakeTidbClusterControl) SetUpdateTidbClusterError added in v0.2.0

func (ssc *FakeTidbClusterControl) SetUpdateTidbClusterError(err error, after int)

SetUpdateTidbClusterError sets the error attributes of updateTidbClusterTracker

func (*FakeTidbClusterControl) UpdateTidbCluster added in v0.2.0

UpdateTidbCluster updates the TidbCluster

type PVCControlInterface

PVCControlInterface manages PVCs used in TidbCluster

func NewRealPVCControl

NewRealPVCControl creates a new PVCControlInterface

type PVControlInterface

type PVControlInterface interface {
	PatchPVReclaimPolicy(*v1alpha1.TidbCluster, *corev1.PersistentVolume, corev1.PersistentVolumeReclaimPolicy) error
	UpdateMetaInfo(*v1alpha1.TidbCluster, *corev1.PersistentVolume) (*corev1.PersistentVolume, error)
}

PVControlInterface manages PVs used in TidbCluster

func NewRealPVControl

NewRealPVControl creates a new PVControlInterface

type PodControlInterface

type PodControlInterface interface {
	// TODO change this to UpdatePod
	UpdateMetaInfo(*v1alpha1.TidbCluster, *corev1.Pod) (*corev1.Pod, error)
	DeletePod(*v1alpha1.TidbCluster, *corev1.Pod) error
	UpdatePod(*v1alpha1.TidbCluster, *corev1.Pod) (*corev1.Pod, error)
}

PodControlInterface manages Pods used in TidbCluster

func NewRealPodControl

func NewRealPodControl(
	kubeCli kubernetes.Interface,
	pdControl pdapi.PDControlInterface,
	podLister corelisters.PodLister,
	recorder record.EventRecorder,
) PodControlInterface

NewRealPodControl creates a new PodControlInterface

type RequeueError added in v0.2.1

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

RequeueError is used to requeue the item, this error type should't be considered as a real error

func (*RequeueError) Error added in v0.2.1

func (re *RequeueError) Error() string

type ServiceControlInterface

type ServiceControlInterface interface {
	CreateService(*v1alpha1.TidbCluster, *corev1.Service) error
	UpdateService(*v1alpha1.TidbCluster, *corev1.Service) (*corev1.Service, error)
	DeleteService(*v1alpha1.TidbCluster, *corev1.Service) error
}

ServiceControlInterface manages Services used in TidbCluster

func NewRealServiceControl

func NewRealServiceControl(kubeCli kubernetes.Interface, svcLister corelisters.ServiceLister, recorder record.EventRecorder) ServiceControlInterface

NewRealServiceControl creates a new ServiceControlInterface

type StatefulSetControlInterface

type StatefulSetControlInterface interface {
	// CreateStatefulSet creates a StatefulSet in a TidbCluster.
	CreateStatefulSet(*v1alpha1.TidbCluster, *apps.StatefulSet) error
	// UpdateStatefulSet updates a StatefulSet in a TidbCluster.
	UpdateStatefulSet(*v1alpha1.TidbCluster, *apps.StatefulSet) (*apps.StatefulSet, error)
	// DeleteStatefulSet deletes a StatefulSet in a TidbCluster.
	DeleteStatefulSet(*v1alpha1.TidbCluster, *apps.StatefulSet) error
}

StatefulSetControlInterface defines the interface that uses to create, update, and delete StatefulSets,

func NewRealStatefuSetControl

func NewRealStatefuSetControl(kubeCli kubernetes.Interface, setLister appslisters.StatefulSetLister, recorder record.EventRecorder) StatefulSetControlInterface

NewRealStatefuSetControl returns a StatefulSetControlInterface

type TiDBControlInterface added in v0.2.0

type TiDBControlInterface interface {
	// GetHealth returns tidb's health info
	GetHealth(tc *v1alpha1.TidbCluster) map[string]bool
	// ResignDDLOwner resigns the ddl owner of tidb, if the tidb node is not a ddl owner returns (true,nil),else returns (false,err)
	ResignDDLOwner(tc *v1alpha1.TidbCluster, ordinal int32) (bool, error)
	// Get TIDB info return tidb's dbInfo
	GetInfo(tc *v1alpha1.TidbCluster, ordinal int32) (*dbInfo, error)
	// GetSettings return the TiDB instance settings
	GetSettings(tc *v1alpha1.TidbCluster, ordinal int32) (*config.Config, error)
}

TiDBControlInterface is the interface that knows how to manage tidb peers

func NewDefaultTiDBControl added in v0.2.0

func NewDefaultTiDBControl() TiDBControlInterface

NewDefaultTiDBControl returns a defaultTiDBControl instance

type TidbClusterControlInterface added in v0.2.0

type TidbClusterControlInterface interface {
	UpdateTidbCluster(*v1alpha1.TidbCluster, *v1alpha1.TidbClusterStatus, *v1alpha1.TidbClusterStatus) (*v1alpha1.TidbCluster, error)
}

TidbClusterControlInterface manages TidbClusters

func NewRealTidbClusterControl added in v0.2.0

func NewRealTidbClusterControl(cli versioned.Interface,
	tcLister listers.TidbClusterLister,
	recorder record.EventRecorder) TidbClusterControlInterface

NewRealTidbClusterControl creates a new TidbClusterControlInterface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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