controller

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: Apache-2.0 Imports: 50 Imported by: 23

Documentation

Index

Constants

View Source
const (
	// LastAppliedPodTemplate is annotation key of the last applied pod template
	LastAppliedPodTemplate = "pingcap.com/last-applied-podtemplate"

	// LastAppliedConfigAnnotation is annotation key of last applied configuration
	LastAppliedConfigAnnotation = "pingcap.com/last-applied-configuration"
)
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")

	// 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

	// TidbDiscoveryImage is the image of tidb discovery service
	TidbDiscoveryImage string

	// PodWebhookEnabled is the key to indicate whether pod admission webhook is set up.
	PodWebhookEnabled bool
)
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 AnnAdditionalProm added in v1.1.0

func AnnAdditionalProm(name string, port int32) map[string]string

AnnAdditionalProm adds additional prometheus scarping configuration annotation for the pod which has multiple metrics endpoint we assumes that the metrics path is as same as the previous metrics path

func AnnProm

func AnnProm(port int32) map[string]string

AnnProm adds annotations for prometheus scraping metrics

func ContainerResource added in v1.1.0

func DeploymentPodSpecChanged added in v1.1.0

func DeploymentPodSpecChanged(newDep *appsv1.Deployment, oldDep *appsv1.Deployment) bool

DeploymentPodSpecChanged checks whether the new deployment differs with the old one's last-applied-config

func DiscoveryMemberName added in v1.1.0

func DiscoveryMemberName(clusterName string) string

DiscoveryMemberName returns the name of tidb discovery

func EmptyClone added in v1.1.0

func EmptyClone(obj runtime.Object) (runtime.Object, error)

EmptyClone create an clone of the resource with the same name and namespace (if namespace-scoped), with other fields unset

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

func GetDeploymentLastAppliedPodTemplate(dep *appsv1.Deployment) (*corev1.PodSpec, error)

GetDeploymentLastAppliedPodTemplate set last applied pod template from Deployment's annotation

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

func GetTiDBMonitorOwnerRef(monitor *v1alpha1.TidbMonitor) metav1.OwnerReference

func GuaranteedUpdate added in v1.1.0

func GuaranteedUpdate(cli client.Client, obj runtime.Object, updateFunc func() error) error

GuaranteedUpdate will retry the updateFunc to mutate the object until success, updateFunc is expected to capture the object reference from the caller context to avoid unnecessary type casting.

func IgnoreErrorf added in v1.1.0

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

IgnoreErrorf returns a IgnoreError

func InferObjectKind added in v1.1.0

func InferObjectKind(obj runtime.Object) (schema.GroupVersionKind, error)

InferObjectKind infers the object kind

func IngressEqual added in v1.1.0

func IngressEqual(newIngress, oldIngres *extensionsv1beta1.Ingress) (bool, error)

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 Deprecated TODO: remove after helm get totally abandoned

func NewDefaultTiCDCControl added in v1.1.0

func NewDefaultTiCDCControl(kubeCli kubernetes.Interface) *defaultTiCDCControl

NewDefaultTiCDCControl returns a defaultTiCDCControl instance

func NewDefaultTiDBControl added in v0.2.0

func NewDefaultTiDBControl(kubeCli kubernetes.Interface) *defaultTiDBControl

NewDefaultTiDBControl returns a defaultTiDBControl instance

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

func ParseStorageRequest(req corev1.ResourceList) (corev1.ResourceRequirements, error)

func PumpMemberName added in v1.1.0

func PumpMemberName(clusterName string) string

PumpMemberName returns pump member name

func PumpPeerMemberName added in v1.1.0

func PumpPeerMemberName(clusterName string) string

For backward compatibility, pump peer member name do not has -peer suffix PumpPeerMemberName returns pump peer service name

func RequeueErrorf added in v0.2.1

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

RequeueErrorf returns a RequeueError

func ServiceEqual added in v1.1.0

func ServiceEqual(newSvc, oldSvc *corev1.Service) (bool, error)

ServiceEqual compares the new Service's spec with old Service's last applied config

func SetServiceLastAppliedConfigAnnotation added in v1.1.0

func SetServiceLastAppliedConfigAnnotation(svc *corev1.Service) error

SetServiceLastAppliedConfigAnnotation set last applied config info to Service's annotation

func TiCDCMemberName added in v1.1.0

func TiCDCMemberName(clusterName string) string

TiCDCMemberName returns ticdc member name

func TiCDCPeerMemberName added in v1.1.0

func TiCDCPeerMemberName(clusterName string) string

TiCDCPeerMemberName returns ticdc peer service name

func TiDBInitializerMemberName added in v1.1.0

func TiDBInitializerMemberName(clusterName string) string

TiDBInitializerMemberName returns TiDBInitializer member name

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

func TiFlashMemberName(clusterName string) string

TiFlashMemberName returns tiflash member name

func TiFlashPeerMemberName added in v1.1.0

func TiFlashPeerMemberName(clusterName string) string

TiFlashPeerMemberName returns tiflash peer service name

func TiKVCapacity

func TiKVCapacity(limits corev1.ResourceList) 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

func WatchForController added in v1.1.0

func WatchForController(informer cache.SharedIndexInformer, q workqueue.Interface, fn GetControllerFn, m map[string]string)

WatchForController watch the object change from informer and add it's controller to workqueue

func WatchForObject added in v1.1.0

func WatchForObject(informer cache.SharedIndexInformer, q workqueue.Interface)

WacthForObject watch the object change from informer and add it to workqueue

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

type CaptureStatus struct {
	ID string `json:"id"`
}

type ConfigMapControlInterface added in v1.1.0

type ConfigMapControlInterface interface {
	// CreateConfigMap create the given ConfigMap owned by the controller object
	CreateConfigMap(controller runtime.Object, cm *corev1.ConfigMap) (*corev1.ConfigMap, error)
	// UpdateConfigMap continuously tries to update ConfigMap to the given state owned by the controller obejct
	UpdateConfigMap(controller runtime.Object, cm *corev1.ConfigMap) (*corev1.ConfigMap, error)
	// DeleteConfigMap delete the given ConfigMap owned by the controller object
	DeleteConfigMap(controller runtime.Object, cm *corev1.ConfigMap) error
	// GetConfigMap get the ConfigMap by configMap name
	GetConfigMap(controller runtime.Object, cm *corev1.ConfigMap) (*corev1.ConfigMap, error)
}

ConfigMapControlInterface manages configmaps used by TiDB clusters

func NewRealConfigMapControl added in v1.1.0

func NewRealConfigMapControl(
	kubeCli kubernetes.Interface,
	recorder record.EventRecorder,
) ConfigMapControlInterface

NewRealSecretControl creates a new SecretControlInterface

type DBInfo added in v1.1.0

type DBInfo struct {
	IsOwner bool `json:"is_owner"`
}

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

type FakeConfigMapControl struct {
	CmIndexer cache.Indexer
	// contains filtered or unexported fields
}

FakeConfigMapControl is a fake ConfigMapControlInterface

func NewFakeConfigMapControl added in v1.1.0

func NewFakeConfigMapControl(cmInformer coreinformers.ConfigMapInformer) *FakeConfigMapControl

NewFakeConfigMapControl returns a FakeConfigMapControl

func (*FakeConfigMapControl) CreateConfigMap added in v1.1.0

func (cc *FakeConfigMapControl) CreateConfigMap(_ runtime.Object, cm *corev1.ConfigMap) (*corev1.ConfigMap, error)

CreateConfigMap adds the ConfigMap to ConfigMapIndexer

func (*FakeConfigMapControl) DeleteConfigMap added in v1.1.0

func (cc *FakeConfigMapControl) DeleteConfigMap(_ runtime.Object, _ *corev1.ConfigMap) error

DeleteConfigMap deletes the ConfigMap of CmIndexer

func (*FakeConfigMapControl) GetConfigMap added in v1.1.1

func (cc *FakeConfigMapControl) GetConfigMap(controller runtime.Object, cm *corev1.ConfigMap) (*corev1.ConfigMap, error)

func (*FakeConfigMapControl) SetCreateConfigMapError added in v1.1.0

func (cc *FakeConfigMapControl) SetCreateConfigMapError(err error, after int)

SetCreateConfigMapError sets the error attributes of createConfigMapTracker

func (*FakeConfigMapControl) SetDeleteConfigMapError added in v1.1.0

func (cc *FakeConfigMapControl) SetDeleteConfigMapError(err error, after int)

SetDeleteConfigMapError sets the error attributes of deleteConfigMapTracker

func (*FakeConfigMapControl) SetUpdateConfigMapError added in v1.1.0

func (cc *FakeConfigMapControl) SetUpdateConfigMapError(err error, after int)

SetUpdateConfigMapError sets the error attributes of updateConfigMapTracker

func (*FakeConfigMapControl) UpdateConfigMap added in v1.1.0

func (cc *FakeConfigMapControl) UpdateConfigMap(_ runtime.Object, cm *corev1.ConfigMap) (*corev1.ConfigMap, error)

UpdateConfigMap updates the ConfigMap of CmIndexer

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

type FakeGenericControl struct {
	FakeCli client.Client
	// contains filtered or unexported fields
}

FakeGenericControl is a fake GenericControlInterface

func NewFakeGenericControl added in v1.1.0

func NewFakeGenericControl(initObjects ...runtime.Object) *FakeGenericControl

NewFakeGenericControl returns a FakeGenericControl

func (*FakeGenericControl) AddObject added in v1.1.0

func (gc *FakeGenericControl) AddObject(object runtime.Object) error

AddObject is used to prepare the indexer for fakeGenericControl

func (*FakeGenericControl) Create added in v1.1.0

func (gc *FakeGenericControl) Create(controller, obj runtime.Object, setOwnerFlag bool) error

func (*FakeGenericControl) CreateOrUpdate added in v1.1.0

func (gc *FakeGenericControl) CreateOrUpdate(controller, obj runtime.Object, fn MergeFn, setOwnerFlag bool) (runtime.Object, error)

func (*FakeGenericControl) Delete added in v1.1.0

func (gc *FakeGenericControl) Delete(controller, obj runtime.Object) error

func (*FakeGenericControl) Exist added in v1.1.0

func (gc *FakeGenericControl) Exist(key client.ObjectKey, obj runtime.Object) (bool, error)

func (*FakeGenericControl) SetCreateError added in v1.1.0

func (gc *FakeGenericControl) SetCreateError(err error, after int)

func (*FakeGenericControl) SetCreateOrUpdateError added in v1.1.0

func (gc *FakeGenericControl) SetCreateOrUpdateError(err error, after int)

func (*FakeGenericControl) SetDeleteError added in v1.1.0

func (gc *FakeGenericControl) SetDeleteError(err error, after int)

func (*FakeGenericControl) SetExistError added in v1.1.0

func (gc *FakeGenericControl) SetExistError(err error, after int)

func (*FakeGenericControl) SetUpdateStatusError added in v1.1.0

func (gc *FakeGenericControl) SetUpdateStatusError(err error, after int)

func (*FakeGenericControl) UpdateStatus added in v1.1.0

func (gc *FakeGenericControl) UpdateStatus(obj runtime.Object) error

UpdateStatus update the /status subresource of object

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(_ runtime.Object, 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

func (fpc *FakePVControl) UpdateMetaInfo(obj runtime.Object, pv *corev1.PersistentVolume) (*corev1.PersistentVolume, error)

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(_ runtime.Object, 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(_ runtime.Object, 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) 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(_ runtime.Object, svc *corev1.Service) error

CreateService adds the service to SvcIndexer

func (*FakeServiceControl) DeleteService

func (ssc *FakeServiceControl) DeleteService(_ runtime.Object, _ *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(_ runtime.Object, 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(_ runtime.Object, set *apps.StatefulSet) error

CreateStatefulSet adds the statefulset to SetIndexer

func (*FakeStatefulSetControl) DeleteStatefulSet

func (ssc *FakeStatefulSetControl) DeleteStatefulSet(_ runtime.Object, _ *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(_ runtime.Object, set *apps.StatefulSet) (*apps.StatefulSet, error)

UpdateStatefulSet updates the statefulset of SetIndexer

type FakeTiCDCControl added in v1.1.0

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

FakeTiCDCControl is a fake implementation of TiCDCControlInterface.

func NewFakeTiCDCControl added in v1.1.0

func NewFakeTiCDCControl() *FakeTiCDCControl

NewFakeTiCDCControl returns a FakeTiCDCControl instance

func (*FakeTiCDCControl) SetStatus added in v1.1.0

func (ftd *FakeTiCDCControl) SetStatus(status *CaptureStatus)

SetHealth set health info for FakeTiCDCControl

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(tc *v1alpha1.TidbCluster, ordinal int32) (bool, error)

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) SetHealth added in v0.2.0

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

SetHealth set health info 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 GenericControlInterface added in v1.1.0

type GenericControlInterface interface {
	CreateOrUpdate(controller, obj runtime.Object, mergeFn MergeFn, setOwnerFlag bool) (runtime.Object, error)
	Create(controller, obj runtime.Object, setOwnerFlag bool) error
	UpdateStatus(obj runtime.Object) error
	Exist(key client.ObjectKey, obj runtime.Object) (bool, error)
	Delete(controller, obj runtime.Object) error
}

GenericControlInterface manages generic object that managed by an arbitrary controller

func NewRealGenericControl added in v1.1.0

func NewRealGenericControl(client client.Client, recorder record.EventRecorder) GenericControlInterface

type GetControllerFn added in v1.1.0

type GetControllerFn func(ns, name string) (runtime.Object, error)

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

type MergeFn func(existing, desired runtime.Object) error

MergeFn knows how to merge a desired object into the current object. Typically, merge should only set the specific fields the caller wants to control to the existing object instead of override a whole struct. e.g.

Prefer:

existing.spec.type = desired.spec.type
existing.spec.externalTrafficPolicy = desired.spec.externalTrafficPolicy

Instead of:

existing.spec = desired.spec

However, this could be tedious for large object if the caller want to control lots of the fields, if there is no one else will mutate this object or cooperation is not needed, it is okay to do aggressive override. Note that aggressive override usually causes unnecessary updates because the object will be mutated after POST/PUT to api-server (e.g. Defaulting), an annotation based technique could be used to avoid such updating: set a last-applied-config annotation and diff the annotation instead of the real spec.

type PVCControlInterface

PVCControlInterface manages PVCs used in TidbCluster

func NewRealPVCControl

NewRealPVCControl creates a new PVCControlInterface

type PVControlInterface

type PVControlInterface interface {
	PatchPVReclaimPolicy(runtime.Object, *corev1.PersistentVolume, corev1.PersistentVolumeReclaimPolicy) error
	UpdateMetaInfo(runtime.Object, *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(runtime.Object, *corev1.Pod) error
	UpdatePod(runtime.Object, *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) GetRequests added in v1.1.0

func (rt *RequestTracker) GetRequests() int

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 {
	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,
) SecretControlInterface

func NewRealSecretControl added in v1.1.0

func NewRealSecretControl(
	kubeCli kubernetes.Interface,
) SecretControlInterface

NewRealSecretControl creates a new SecretControlInterface

type ServiceControlInterface

type ServiceControlInterface interface {
	CreateService(runtime.Object, *corev1.Service) error
	UpdateService(runtime.Object, *corev1.Service) (*corev1.Service, error)
	DeleteService(runtime.Object, *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(runtime.Object, *apps.StatefulSet) error
	UpdateStatefulSet(runtime.Object, *apps.StatefulSet) (*apps.StatefulSet, error)
	DeleteStatefulSet(runtime.Object, *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 TiCDCControlInterface added in v1.1.0

type TiCDCControlInterface interface {
	// GetStatus returns ticdc's status
	GetStatus(tc *v1alpha1.TidbCluster, ordinal int32) (*CaptureStatus, error)
}

TiCDCControlInterface is the interface that knows how to manage ticdc captures

type TiDBControlInterface added in v0.2.0

type TiDBControlInterface interface {
	// GetHealth returns tidb's health info
	GetHealth(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

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

type TypedControlInterface added in v1.1.0

type TypedControlInterface interface {
	// CreateOrUpdateSecret create the desired secret or update the current one to desired state if already existed
	CreateOrUpdateSecret(controller runtime.Object, secret *corev1.Secret) (*corev1.Secret, error)
	// CreateOrUpdateConfigMap create the desired configmap or update the current one to desired state if already existed
	CreateOrUpdateConfigMap(controller runtime.Object, cm *corev1.ConfigMap) (*corev1.ConfigMap, error)
	// CreateOrUpdateClusterRole the desired clusterRole or update the current one to desired state if already existed
	CreateOrUpdateClusterRole(controller runtime.Object, clusterRole *rbacv1.ClusterRole) (*rbacv1.ClusterRole, error)
	// CreateOrUpdateClusterRoleBinding create the desired clusterRoleBinding or update the current one to desired state if already existed
	CreateOrUpdateClusterRoleBinding(controller runtime.Object, crb *rbacv1.ClusterRoleBinding) (*rbacv1.ClusterRoleBinding, error)
	// CreateOrUpdateRole create the desired role or update the current one to desired state if already existed
	CreateOrUpdateRole(controller runtime.Object, role *rbacv1.Role) (*rbacv1.Role, error)
	// CreateOrUpdateRoleBinding create the desired rolebinding or update the current one to desired state if already existed
	CreateOrUpdateRoleBinding(controller runtime.Object, cr *rbacv1.RoleBinding) (*rbacv1.RoleBinding, error)
	// CreateOrUpdateServiceAccount create the desired serviceaccount or update the current one to desired state if already existed
	CreateOrUpdateServiceAccount(controller runtime.Object, sa *corev1.ServiceAccount) (*corev1.ServiceAccount, error)
	// CreateOrUpdateService create the desired service or update the current one to desired state if already existed
	CreateOrUpdateService(controller runtime.Object, svc *corev1.Service) (*corev1.Service, error)
	// CreateOrUpdateDeployment create the desired deployment or update the current one to desired state if already existed
	CreateOrUpdateDeployment(controller runtime.Object, deploy *appsv1.Deployment) (*appsv1.Deployment, error)
	// CreateOrUpdatePVC create the desired pvc or update the current one to desired state if already existed
	CreateOrUpdatePVC(controller runtime.Object, pvc *corev1.PersistentVolumeClaim, setOwnerFlag bool) (*corev1.PersistentVolumeClaim, error)
	// CreateOrUpdateIngress create the desired ingress or update the current one to desired state if already existed
	CreateOrUpdateIngress(controller runtime.Object, ingress *extensionsv1beta1.Ingress) (*extensionsv1beta1.Ingress, error)
	// UpdateStatus update the /status subresource of the object
	UpdateStatus(newStatus runtime.Object) error
	// Delete delete the given object from the cluster
	Delete(controller, obj runtime.Object) error
	// Create create the given object for the controller
	Create(controller, obj runtime.Object) error
	// Exist check whether object exists
	Exist(key client.ObjectKey, obj runtime.Object) (bool, error)
}

GenericControlInterface is a wrapper to manage typed object that managed by an arbitrary controller

func NewTypedControl added in v1.1.0

func NewTypedControl(control GenericControlInterface) TypedControlInterface

NewTypedControl wraps a GenericControlInterface to a TypedControlInterface

Directories

Path Synopsis
Package periodicity dedicate the periodicity controller.
Package periodicity dedicate the periodicity controller.

Jump to

Keyboard shortcuts

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