controller

package
v1.1.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: Apache-2.0 Imports: 44 Imported by: 40

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 (
	// controllerKind contains the schema.GroupVersionKind for tidbcluster controller type.
	ControllerKind = v1alpha1.SchemeGroupVersion.WithKind("TidbCluster")

	// BackupControllerKind contains the schema.GroupVersionKind for backup controller type.
	BackupControllerKind = v1alpha1.SchemeGroupVersion.WithKind("Backup")

	// RestoreControllerKind contains the schema.GroupVersionKind for restore controller type.
	RestoreControllerKind = v1alpha1.SchemeGroupVersion.WithKind("Restore")

	// DefaultStorageClassName is the default storageClassName
	DefaultStorageClassName string

	// DefaultBackupStorageClassName is the default storageClassName for backup and restore job
	DefaultBackupStorageClassName string

	// TidbBackupManagerImage is the image of tidb backup manager tool
	TidbBackupManagerImage 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 GetBackupOwnerRef added in v1.1.0

func GetBackupOwnerRef(backup *v1alpha1.Backup) metav1.OwnerReference

GetBackupOwnerRef returns Backup's OwnerReference

func GetBackupScheduleOwnerRef added in v1.1.0

func GetBackupScheduleOwnerRef(bs *v1alpha1.BackupSchedule) metav1.OwnerReference

GetBackupScheduleOwnerRef returns BackupSchedule's OwnerReference

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 GetRestoreOwnerRef added in v1.1.0

func GetRestoreOwnerRef(restore *v1alpha1.Restore) metav1.OwnerReference

GetRestoreOwnerRef returns Restore's OwnerReference

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 GetUtilImage

func GetUtilImage(cluster *v1alpha1.TidbCluster) string

Reuse the SlowLogTailer image for TiDB

func IgnoreErrorf added in v1.1.0

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

IgnoreErrorf returns a IgnoreError

func Int32Ptr added in v1.0.2

func Int32Ptr(i int32) *int32

Int32Ptr returns a pointer to an int32

func IsIgnoreError added in v1.1.0

func IsIgnoreError(err error) bool

IsIgnoreError returns whether err is a IgnoreError

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. In tikv-server, KB/MB/GB equal to MiB/GiB/TiB, so we cannot use resource.String() directly. Minimum unit we use is MiB, capacity less than 1MiB is ignored. https://github.com/tikv/tikv/blob/v3.0.3/components/tikv_util/src/config.rs#L155-L168 For backward compatibility with old TiKV versions, we should use GB/MB rather than GiB/MiB, see https://github.com/tikv/tikv/blob/v2.1.16/src/util/config.rs#L359.

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 BackupConditionUpdaterInterface added in v1.1.0

type BackupConditionUpdaterInterface interface {
	Update(backup *v1alpha1.Backup, condition *v1alpha1.BackupCondition) error
}

BackupConditionUpdaterInterface enables updating Backup conditions.

func NewRealBackupConditionUpdater added in v1.1.0

func NewRealBackupConditionUpdater(
	cli versioned.Interface,
	backupLister listers.BackupLister,
	recorder record.EventRecorder) BackupConditionUpdaterInterface

returns a BackupConditionUpdaterInterface that updates the Status of a Backup,

type BackupControlInterface added in v1.1.0

type BackupControlInterface interface {
	CreateBackup(backup *v1alpha1.Backup) (*v1alpha1.Backup, error)
	DeleteBackup(backup *v1alpha1.Backup) error
}

BackupControlInterface manages Backups used in BackupSchedule

func NewRealBackupControl added in v1.1.0

func NewRealBackupControl(
	cli versioned.Interface,
	recorder record.EventRecorder,
) BackupControlInterface

NewRealBackupControl creates a new BackupControlInterface

type BackupScheduleStatusUpdaterInterface added in v1.1.0

type BackupScheduleStatusUpdaterInterface interface {
	// UpdateBackupScheduleStatus sets the backupSchedule's Status to status. Implementations are required to retry on conflicts,
	// but fail on other errors. If the returned error is nil backup's Status has been successfully set to status.
	UpdateBackupScheduleStatus(*v1alpha1.BackupSchedule, *v1alpha1.BackupScheduleStatus, *v1alpha1.BackupScheduleStatus) error
}

BackupScheduleStatusUpdaterInterface is an interface used to update the BackupScheduleStatus associated with a BackupSchedule. For any use other than testing, clients should create an instance using NewRealBackupScheduleStatusUpdater.

func NewRealBackupScheduleStatusUpdater added in v1.1.0

func NewRealBackupScheduleStatusUpdater(
	cli versioned.Interface,
	bsLister listers.BackupScheduleLister,
	recorder record.EventRecorder) BackupScheduleStatusUpdaterInterface

returns a BackupScheduleStatusUpdaterInterface that updates the Status of a BackupSchedule, using the supplied client and bsLister.

type CertControlInterface

type CertControlInterface interface {
	Create(or metav1.OwnerReference, certOpts *TiDBClusterCertOptions) error
	CheckSecret(ns string, secretName string) bool
}

CertControlInterface manages certificates used by TiDB clusters

func NewRealCertControl

NewRealCertControl creates a new CertControlInterface

type FakeBackupConditionUpdater added in v1.1.0

type FakeBackupConditionUpdater struct {
	BackupLister  listers.BackupLister
	BackupIndexer cache.Indexer
	// contains filtered or unexported fields
}

FakeBackupConditionUpdater is a fake BackupConditionUpdaterInterface

func NewFakeBackupConditionUpdater added in v1.1.0

func NewFakeBackupConditionUpdater(backupInformer informers.BackupInformer) *FakeBackupConditionUpdater

NewFakeBackupConditionUpdater returns a FakeBackupConditionUpdater

func (*FakeBackupConditionUpdater) SetUpdateBackupError added in v1.1.0

func (fbc *FakeBackupConditionUpdater) SetUpdateBackupError(err error, after int)

SetUpdateBackupError sets the error attributes of updateBackupTracker

func (*FakeBackupConditionUpdater) Update added in v1.1.0

UpdateBackup updates the Backup

type FakeBackupControl added in v1.1.0

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

FakeBackupControl is a fake BackupControlInterface

func NewFakeBackupControl added in v1.1.0

func NewFakeBackupControl(backupInformer informers.BackupInformer) *FakeBackupControl

NewFakeBackupControl returns a FakeBackupControl

func (*FakeBackupControl) CreateBackup added in v1.1.0

func (fbc *FakeBackupControl) CreateBackup(backup *v1alpha1.Backup) (*v1alpha1.Backup, error)

CreateBackup adds the backup to BackupIndexer

func (*FakeBackupControl) DeleteBackup added in v1.1.0

func (fbc *FakeBackupControl) DeleteBackup(backup *v1alpha1.Backup) error

DeleteBackup deletes the backup from BackupIndexer

func (*FakeBackupControl) SetCreateBackupError added in v1.1.0

func (fbc *FakeBackupControl) SetCreateBackupError(err error, after int)

SetCreateBackupError sets the error attributes of createBackupTracker

func (*FakeBackupControl) SetDeleteBackupError added in v1.1.0

func (fbc *FakeBackupControl) SetDeleteBackupError(err error, after int)

SetDeleteBackupError sets the error attributes of deleteBackupTracker

type FakeBackupScheduleStatusUpdater added in v1.1.0

type FakeBackupScheduleStatusUpdater struct {
	BsLister  listers.BackupScheduleLister
	BsIndexer cache.Indexer
	// contains filtered or unexported fields
}

FakeBackupScheduleStatusUpdater is a fake BackupScheduleStatusUpdaterInterface

func NewFakeBackupScheduleStatusUpdater added in v1.1.0

func NewFakeBackupScheduleStatusUpdater(bsInformer informers.BackupScheduleInformer) *FakeBackupScheduleStatusUpdater

NewFakeBackupScheduleStatusUpdater returns a FakeBackupScheduleStatusUpdater

func (*FakeBackupScheduleStatusUpdater) SetUpdateBackupScheduleError added in v1.1.0

func (fbs *FakeBackupScheduleStatusUpdater) SetUpdateBackupScheduleError(err error, after int)

SetUpdateBackupError sets the error attributes of updateBackupScheduleTracker

func (*FakeBackupScheduleStatusUpdater) UpdateBackupScheduleStatus added in v1.1.0

UpdateBackupSchedule updates the BackupSchedule

type FakeCertControl

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

func (*FakeCertControl) CheckSecret

func (rcc *FakeCertControl) CheckSecret(ns string, secretName string) bool

func (*FakeCertControl) Create

func (rcc *FakeCertControl) Create(or metav1.OwnerReference, certOpts *TiDBClusterCertOptions) error

type FakeGeneralPVCControl added in v1.1.0

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

FakeGeneralPVCControl is a fake GeneralPVCControlInterface

func NewFakeGeneralPVCControl added in v1.1.0

func NewFakeGeneralPVCControl(pvcInformer coreinformers.PersistentVolumeClaimInformer) *FakeGeneralPVCControl

NewFakeGeneralPVCControl returns a FakeGeneralPVCControl

func (*FakeGeneralPVCControl) CreatePVC added in v1.1.0

CreatePVC adds the pvc to PVCIndexer

func (*FakeGeneralPVCControl) SetCreatePVCError added in v1.1.0

func (fjc *FakeGeneralPVCControl) SetCreatePVCError(err error, after int)

SetCreatePVCError sets the error attributes of createPVCTracker

type FakeJobControl added in v1.1.0

type FakeJobControl struct {
	JobLister  batchlisters.JobLister
	JobIndexer cache.Indexer
	// contains filtered or unexported fields
}

FakeJobControl is a fake JobControlInterface

func NewFakeJobControl added in v1.1.0

func NewFakeJobControl(jobInformer batchinformers.JobInformer) *FakeJobControl

NewFakeJobControl returns a FakeJobControl

func (*FakeJobControl) CreateJob added in v1.1.0

func (fjc *FakeJobControl) CreateJob(_ runtime.Object, job *batchv1.Job) error

CreateJob adds the job to JobIndexer

func (*FakeJobControl) DeleteJob added in v1.1.0

func (fjc *FakeJobControl) DeleteJob(_ runtime.Object, _ *batchv1.Job) error

DeleteJob deletes the job

func (*FakeJobControl) SetCreateJobError added in v1.1.0

func (fjc *FakeJobControl) SetCreateJobError(err error, after int)

SetCreateJobError sets the error attributes of createJobTracker

func (*FakeJobControl) SetDeleteJobError added in v1.1.0

func (fjc *FakeJobControl) SetDeleteJobError(err error, after int)

SetDeleteJobError sets the error attributes of deleteJobTracker

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) GetPVC added in v1.1.0

func (fpc *FakePVCControl) GetPVC(name, namespace string) (*corev1.PersistentVolumeClaim, error)

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 FakeRestoreConditionUpdater added in v1.1.0

type FakeRestoreConditionUpdater struct {
	RestoreLister  listers.RestoreLister
	RestoreIndexer cache.Indexer
	// contains filtered or unexported fields
}

FakeRestoreConditionUpdater is a fake RestoreConditionUpdaterInterface

func NewFakeRestoreConditionUpdater added in v1.1.0

func NewFakeRestoreConditionUpdater(restoreInformer informers.RestoreInformer) *FakeRestoreConditionUpdater

NewFakeRestoreConditionUpdater returns a FakeRestoreConditionUpdater

func (*FakeRestoreConditionUpdater) SetUpdateRestoreError added in v1.1.0

func (frc *FakeRestoreConditionUpdater) SetUpdateRestoreError(err error, after int)

SetUpdateRestoreError sets the error attributes of updateRestoreTracker

func (*FakeRestoreConditionUpdater) Update added in v1.1.0

UpdateRestore updates the Restore

type FakeSecretControl added in v1.1.0

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

func (*FakeSecretControl) Check added in v1.1.0

func (rsc *FakeSecretControl) Check(ns string, secretName string) bool

Check returns true if the secret already exist

func (*FakeSecretControl) Create added in v1.4.0

func (rsc *FakeSecretControl) Create(or metav1.OwnerReference, certOpts *TiDBClusterCertOptions, cert []byte, key []byte) error

func (*FakeSecretControl) Load added in v1.1.0

func (rsc *FakeSecretControl) Load(ns string, secretName string) ([]byte, []byte, error)

Load loads cert and key from Secret matching the name

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 GeneralPVCControlInterface added in v1.1.0

type GeneralPVCControlInterface interface {
	CreatePVC(object runtime.Object, pvc *corev1.PersistentVolumeClaim) error
}

GeneralPVCControlInterface manages PVCs used in backup and restore's pvc

func NewRealGeneralPVCControl added in v1.1.0

func NewRealGeneralPVCControl(
	kubeCli kubernetes.Interface,
	recorder record.EventRecorder,
) GeneralPVCControlInterface

NewRealGeneralPVCControl creates a new GeneralPVCControlInterface

type IgnoreError added in v1.1.0

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

IgnoreError is used to ignore this item, this error type should't be considered as a real error, no need to requeue

func (*IgnoreError) Error added in v1.1.0

func (re *IgnoreError) Error() string

type JobControlInterface added in v1.1.0

type JobControlInterface interface {
	CreateJob(object runtime.Object, job *batchv1.Job) error
	DeleteJob(object runtime.Object, job *batchv1.Job) error
}

JobControlInterface manages Jobs used in backup、restore and clean

func NewRealJobControl added in v1.1.0

func NewRealJobControl(
	kubeCli kubernetes.Interface,
	recorder record.EventRecorder,
) JobControlInterface

NewRealJobControl creates a new JobControlInterface

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 RequestTracker added in v1.1.0

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

RequestTracker is used by unit test for mocking request error

func (*RequestTracker) ErrorReady added in v1.1.0

func (rt *RequestTracker) ErrorReady() bool

func (*RequestTracker) GetError added in v1.1.0

func (rt *RequestTracker) GetError() error

func (*RequestTracker) Inc added in v1.1.0

func (rt *RequestTracker) Inc()

func (*RequestTracker) Reset added in v1.1.0

func (rt *RequestTracker) Reset()

func (*RequestTracker) SetAfter added in v1.1.0

func (rt *RequestTracker) SetAfter(after int) *RequestTracker

func (*RequestTracker) SetError added in v1.1.0

func (rt *RequestTracker) SetError(err error) *RequestTracker

func (*RequestTracker) SetRequests added in v1.1.0

func (rt *RequestTracker) SetRequests(requests int) *RequestTracker

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 RestoreConditionUpdaterInterface added in v1.1.0

type RestoreConditionUpdaterInterface interface {
	Update(restore *v1alpha1.Restore, condition *v1alpha1.RestoreCondition) error
}

RestoreConditionUpdaterInterface enables updating Restore conditions.

func NewRealRestoreConditionUpdater added in v1.1.0

func NewRealRestoreConditionUpdater(
	cli versioned.Interface,
	restoreLister listers.RestoreLister,
	recorder record.EventRecorder) RestoreConditionUpdaterInterface

returns a RestoreConditionUpdaterInterface that updates the Status of a Restore,

type SecretControlInterface added in v1.1.0

type SecretControlInterface interface {
	Create(or metav1.OwnerReference, certOpts *TiDBClusterCertOptions, cert []byte, key []byte) error
	Load(ns string, secretName string) ([]byte, []byte, error)
	Check(ns string, secretName string) bool
}

SecretControlInterface manages certificates used by TiDB clusters

func NewFakeSecretControl added in v1.1.0

func NewFakeSecretControl(
	kubeCli kubernetes.Interface,
	secretLister corelisters.SecretLister,
) SecretControlInterface

func NewRealSecretControl added in v1.1.0

func NewRealSecretControl(
	kubeCli kubernetes.Interface,
	secretLister corelisters.SecretLister,
) SecretControlInterface

NewRealSecretControl creates a new SecretControlInterface

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 TiDBClusterCertOptions

type TiDBClusterCertOptions struct {
	Namespace  string
	Instance   string
	CommonName string
	HostList   []string
	IPList     []string
	Suffix     string
	Component  string
}

TiDBClusterCertOptions contains information needed to create new certificates

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