Documentation ¶
Index ¶
- Constants
- func CombineAnnotations(a, b map[string]string) map[string]string
- func GetLastAppliedConfig(set *apps.StatefulSet) (*apps.StatefulSetSpec, *corev1.PodSpec, error)
- func NeedForceUpgrade(tc *v1alpha1.TidbCluster) bool
- func NewPDMemberManager(pdControl pdapi.PDControlInterface, ...) manager.Manager
- func NewTiDBMemberManager(setControl controller.StatefulSetControlInterface, ...) manager.Manager
- func NewTiKVMemberManager(pdControl pdapi.PDControlInterface, ...) manager.Manager
- func PdPodName(tcName string, ordinal int32) string
- func SetLastAppliedConfigAnnotation(set *apps.StatefulSet) error
- func SetServiceLastAppliedConfigAnnotation(svc *corev1.Service) error
- type Failover
- func NewFakePDFailover() Failover
- func NewFakeTiDBFailover() Failover
- func NewFakeTiKVFailover() Failover
- func NewPDFailover(cli versioned.Interface, pdControl pdapi.PDControlInterface, ...) Failover
- func NewTiDBFailover(failoverPeriod time.Duration) Failover
- func NewTiKVFailover(tikvFailoverPeriod time.Duration) Failover
- type FakeOrphanPodsCleaner
- type FakePDMemberManager
- type FakePVCCleaner
- type FakeTiDBMemberManager
- type FakeTiKVMemberManager
- type OrphanPodsCleaner
- type PVCCleanerInterface
- type Scaler
- type SvcConfig
- type Upgrader
- func NewFakePDUpgrader() Upgrader
- func NewFakeTiDBUpgrader() Upgrader
- func NewFakeTiKVUpgrader() Upgrader
- func NewPDUpgrader(pdControl pdapi.PDControlInterface, podControl controller.PodControlInterface, ...) Upgrader
- func NewTiDBUpgrader(tidbControl controller.TiDBControlInterface, podLister corelisters.PodLister) Upgrader
- func NewTiKVUpgrader(pdControl pdapi.PDControlInterface, podControl controller.PodControlInterface, ...) Upgrader
Constants ¶
const ( // EvictLeaderBeginTime is the key of evict Leader begin time EvictLeaderBeginTime = "evictLeaderBeginTime" // EvictLeaderTimeout is the timeout limit of evict leader EvictLeaderTimeout = 3 * time.Minute )
const ( // LastAppliedConfigAnnotation is annotation key of last applied configuration LastAppliedConfigAnnotation = "pingcap.com/last-applied-configuration" // ImagePullBackOff is the pod state of image pull failed ImagePullBackOff = "ImagePullBackOff" // ErrImagePull is the pod state of image pull failed ErrImagePull = "ErrImagePull" )
const (
// MaxResignDDLOwnerCount is the max regign DDL owner count
MaxResignDDLOwnerCount = 3
)
Variables ¶
This section is empty.
Functions ¶
func CombineAnnotations ¶ added in v1.0.0
CombineAnnotations merges two annotations maps
func GetLastAppliedConfig ¶
func GetLastAppliedConfig(set *apps.StatefulSet) (*apps.StatefulSetSpec, *corev1.PodSpec, error)
GetLastAppliedConfig get last applied config info from Statefulset's annotation
func NeedForceUpgrade ¶ added in v1.1.0
func NeedForceUpgrade(tc *v1alpha1.TidbCluster) bool
NeedForceUpgrade check if force upgrade is necessary
func NewPDMemberManager ¶
func NewPDMemberManager(pdControl pdapi.PDControlInterface, setControl controller.StatefulSetControlInterface, svcControl controller.ServiceControlInterface, podControl controller.PodControlInterface, certControl controller.CertControlInterface, setLister v1.StatefulSetLister, svcLister corelisters.ServiceLister, podLister corelisters.PodLister, epsLister corelisters.EndpointsLister, pvcLister corelisters.PersistentVolumeClaimLister, pdScaler Scaler, pdUpgrader Upgrader, autoFailover bool, pdFailover Failover) manager.Manager
NewPDMemberManager returns a *pdMemberManager
func NewTiDBMemberManager ¶
func NewTiDBMemberManager(setControl controller.StatefulSetControlInterface, svcControl controller.ServiceControlInterface, tidbControl controller.TiDBControlInterface, certControl controller.CertControlInterface, setLister v1.StatefulSetLister, svcLister corelisters.ServiceLister, podLister corelisters.PodLister, tidbUpgrader Upgrader, autoFailover bool, tidbFailover Failover) manager.Manager
NewTiDBMemberManager returns a *tidbMemberManager
func NewTiKVMemberManager ¶
func NewTiKVMemberManager(pdControl pdapi.PDControlInterface, setControl controller.StatefulSetControlInterface, svcControl controller.ServiceControlInterface, certControl controller.CertControlInterface, setLister v1.StatefulSetLister, svcLister corelisters.ServiceLister, podLister corelisters.PodLister, nodeLister corelisters.NodeLister, autoFailover bool, tikvFailover Failover, tikvScaler Scaler, tikvUpgrader Upgrader) manager.Manager
NewTiKVMemberManager returns a *tikvMemberManager
func SetLastAppliedConfigAnnotation ¶
func SetLastAppliedConfigAnnotation(set *apps.StatefulSet) error
SetLastAppliedConfigAnnotation set last applied config info to Statefulset's annotation
func SetServiceLastAppliedConfigAnnotation ¶
SetServiceLastAppliedConfigAnnotation set last applied config info to Service's annotation
Types ¶
type Failover ¶ added in v0.2.0
type Failover interface { Failover(*v1alpha1.TidbCluster) error Recover(*v1alpha1.TidbCluster) }
Failover implements the logic for pd/tikv/tidb's failover and recovery.
func NewFakePDFailover ¶ added in v0.2.0
func NewFakePDFailover() Failover
NewFakePDFailover returns a fake Failover
func NewFakeTiDBFailover ¶ added in v0.2.0
func NewFakeTiDBFailover() Failover
NewFakeTiDBFailover returns a fake Failover
func NewFakeTiKVFailover ¶ added in v0.2.0
func NewFakeTiKVFailover() Failover
NewFakeTiKVFailover returns a fake Failover
func NewPDFailover ¶ added in v0.2.0
func NewPDFailover(cli versioned.Interface, pdControl pdapi.PDControlInterface, pdFailoverPeriod time.Duration, podLister corelisters.PodLister, podControl controller.PodControlInterface, pvcLister corelisters.PersistentVolumeClaimLister, pvcControl controller.PVCControlInterface, pvLister corelisters.PersistentVolumeLister) Failover
NewPDFailover returns a pd Failover
func NewTiDBFailover ¶ added in v0.2.0
NewTiDBFailover returns a tidbFailover instance
func NewTiKVFailover ¶ added in v0.2.0
NewTiKVFailover returns a tikv Failover
type FakeOrphanPodsCleaner ¶ added in v1.1.0
type FakeOrphanPodsCleaner struct {
// contains filtered or unexported fields
}
func NewFakeOrphanPodsCleaner ¶ added in v1.0.0
func NewFakeOrphanPodsCleaner() *FakeOrphanPodsCleaner
NewFakeOrphanPodsCleaner returns a fake orphan pods cleaner
func (*FakeOrphanPodsCleaner) Clean ¶ added in v1.1.0
func (fpc *FakeOrphanPodsCleaner) Clean(_ *v1alpha1.TidbCluster) (map[string]string, error)
func (*FakeOrphanPodsCleaner) SetnOrphanPodCleanerError ¶ added in v1.1.0
func (fpc *FakeOrphanPodsCleaner) SetnOrphanPodCleanerError(err error)
type FakePDMemberManager ¶ added in v0.4.0
type FakePDMemberManager struct {
// contains filtered or unexported fields
}
func NewFakePDMemberManager ¶ added in v0.4.0
func NewFakePDMemberManager() *FakePDMemberManager
func (*FakePDMemberManager) SetSyncError ¶ added in v0.4.0
func (fpmm *FakePDMemberManager) SetSyncError(err error)
func (*FakePDMemberManager) Sync ¶ added in v0.4.0
func (fpmm *FakePDMemberManager) Sync(tc *v1alpha1.TidbCluster) error
type FakePVCCleaner ¶ added in v1.1.0
type FakePVCCleaner struct {
// contains filtered or unexported fields
}
func NewFakePVCCleaner ¶ added in v1.0.1
func NewFakePVCCleaner() *FakePVCCleaner
NewFakePVCCleaner returns a fake PVC cleaner
func (*FakePVCCleaner) Clean ¶ added in v1.1.0
func (fpc *FakePVCCleaner) Clean(_ *v1alpha1.TidbCluster) (map[string]string, error)
func (*FakePVCCleaner) SetPVCCleanerError ¶ added in v1.1.0
func (fpc *FakePVCCleaner) SetPVCCleanerError(err error)
type FakeTiDBMemberManager ¶ added in v0.4.0
type FakeTiDBMemberManager struct {
// contains filtered or unexported fields
}
func NewFakeTiDBMemberManager ¶ added in v0.4.0
func NewFakeTiDBMemberManager() *FakeTiDBMemberManager
func (*FakeTiDBMemberManager) SetSyncError ¶ added in v0.4.0
func (ftmm *FakeTiDBMemberManager) SetSyncError(err error)
func (*FakeTiDBMemberManager) Sync ¶ added in v0.4.0
func (ftmm *FakeTiDBMemberManager) Sync(tc *v1alpha1.TidbCluster) error
type FakeTiKVMemberManager ¶ added in v0.4.0
type FakeTiKVMemberManager struct {
// contains filtered or unexported fields
}
func NewFakeTiKVMemberManager ¶ added in v0.4.0
func NewFakeTiKVMemberManager() *FakeTiKVMemberManager
func (*FakeTiKVMemberManager) SetSyncError ¶ added in v0.4.0
func (ftmm *FakeTiKVMemberManager) SetSyncError(err error)
func (*FakeTiKVMemberManager) Sync ¶ added in v0.4.0
func (ftmm *FakeTiKVMemberManager) Sync(tc *v1alpha1.TidbCluster) error
type OrphanPodsCleaner ¶ added in v1.0.0
type OrphanPodsCleaner interface {
Clean(*v1alpha1.TidbCluster) (map[string]string, error)
}
OrphanPodsCleaner implements the logic for cleaning the orphan pods(has no pvc)
In scaling out and failover, we will try to delete the old PVC to prevent it from being used by the new pod. However, the PVC might not be deleted immediately in the apiserver because of finalizers (e.g. kubernetes.io/pvc-protection) and the statefulset controller may not have received PVC delete event when it tries to create the new replica and the new pod will be pending forever because no PVC to use. We need to clean these orphan pods and let the statefulset controller to create PVC(s) for them.
func NewOrphanPodsCleaner ¶ added in v1.0.0
func NewOrphanPodsCleaner(podLister corelisters.PodLister, podControl controller.PodControlInterface, pvcLister corelisters.PersistentVolumeClaimLister, kubeCli kubernetes.Interface) OrphanPodsCleaner
NewOrphanPodsCleaner returns a OrphanPodsCleaner
type PVCCleanerInterface ¶ added in v1.0.1
type PVCCleanerInterface interface {
Clean(*v1alpha1.TidbCluster) (map[string]string, error)
}
PVCCleaner implements the logic for cleaning the pvc related resource
func NewRealPVCCleaner ¶ added in v1.0.1
func NewRealPVCCleaner( kubeCli kubernetes.Interface, podLister corelisters.PodLister, pvcControl controller.PVCControlInterface, pvcLister corelisters.PersistentVolumeClaimLister, pvLister corelisters.PersistentVolumeLister, pvControl controller.PVControlInterface) PVCCleanerInterface
NewRealPVCCleaner returns a realPVCCleaner
type Scaler ¶
type Scaler interface { // ScaleOut scales out the cluster ScaleOut(*v1alpha1.TidbCluster, *apps.StatefulSet, *apps.StatefulSet) error // ScaleIn scales in the cluster ScaleIn(*v1alpha1.TidbCluster, *apps.StatefulSet, *apps.StatefulSet) error }
Scaler implements the logic for scaling out or scaling in the cluster.
func NewFakeTiKVScaler ¶
func NewFakeTiKVScaler() Scaler
NewFakeTiKVScaler returns a fake tikv Scaler
func NewPDScaler ¶
func NewPDScaler(pdControl pdapi.PDControlInterface, pvcLister corelisters.PersistentVolumeClaimLister, pvcControl controller.PVCControlInterface) Scaler
NewPDScaler returns a Scaler
func NewTiKVScaler ¶
func NewTiKVScaler(pdControl pdapi.PDControlInterface, pvcLister corelisters.PersistentVolumeClaimLister, pvcControl controller.PVCControlInterface, podLister corelisters.PodLister) Scaler
NewTiKVScaler returns a tikv Scaler
type SvcConfig ¶
type SvcConfig struct { Name string Port int32 SvcLabel func(label.Label) label.Label MemberName func(clusterName string) string Headless bool }
SvcConfig corresponds to a K8s service
type Upgrader ¶ added in v0.2.0
type Upgrader interface { // Upgrade upgrade the cluster Upgrade(*v1alpha1.TidbCluster, *apps.StatefulSet, *apps.StatefulSet) error }
Upgrader implements the logic for upgrading the tidb cluster.
func NewFakePDUpgrader ¶ added in v0.2.0
func NewFakePDUpgrader() Upgrader
NewFakePDUpgrader returns a fakePDUpgrader
func NewFakeTiDBUpgrader ¶ added in v0.2.0
func NewFakeTiDBUpgrader() Upgrader
NewFakeTiDBUpgrader returns a fake tidb upgrader
func NewFakeTiKVUpgrader ¶ added in v0.2.0
func NewFakeTiKVUpgrader() Upgrader
NewFakeTiKVUpgrader returns a fake tikv upgrader
func NewPDUpgrader ¶ added in v0.2.0
func NewPDUpgrader(pdControl pdapi.PDControlInterface, podControl controller.PodControlInterface, podLister corelisters.PodLister) Upgrader
NewPDUpgrader returns a pdUpgrader
func NewTiDBUpgrader ¶ added in v0.2.0
func NewTiDBUpgrader(tidbControl controller.TiDBControlInterface, podLister corelisters.PodLister) Upgrader
NewTiDBUpgrader returns a tidb Upgrader
func NewTiKVUpgrader ¶ added in v0.2.0
func NewTiKVUpgrader(pdControl pdapi.PDControlInterface, podControl controller.PodControlInterface, podLister corelisters.PodLister) Upgrader
NewTiKVUpgrader returns a tikv Upgrader