member

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// EvictLeaderBeginTime is the key of evict Leader begin time
	EvictLeaderBeginTime = "evictLeaderBeginTime"
	// EvictLeaderTimeout is the timeout limit of evict leader
	EvictLeaderTimeout = 3 * time.Minute
)
View Source
const (
	// LastAppliedConfigAnnotation is annotation key of last applied configuration
	LastAppliedConfigAnnotation = "tikv.org/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"
)

Variables

This section is empty.

Functions

func AddConfigMapDigestSuffix

func AddConfigMapDigestSuffix(cm *corev1.ConfigMap) error

func CombineAnnotations

func CombineAnnotations(a, b map[string]string) map[string]string

CombineAnnotations merges two annotations maps

func FindConfigMapVolume

func FindConfigMapVolume(podSpec *corev1.PodSpec, pred func(string) bool) string

FindConfigMapVolume returns the configmap which's name matches the predicate in a PodSpec, empty indicates not found

func GetLastAppliedConfig

func GetLastAppliedConfig(set *apps.StatefulSet) (*apps.StatefulSetSpec, *corev1.PodSpec, error)

GetLastAppliedConfig get last applied config info from Statefulset's annotation and the podTemplate's annotation

func MapContainers

func MapContainers(podSpec *corev1.PodSpec) map[string]corev1.Container

MapContainers index containers of Pod by container name in favor of looking up

func MarshalTOML

func MarshalTOML(v interface{}) ([]byte, error)

MarshalTOML is a template function that try to marshal a go value to toml

func MemberPodName

func MemberPodName(tcName string, ordinal int32, memberType v1alpha1.MemberType) string

func NeedForceUpgrade

func NeedForceUpgrade(tc *v1alpha1.TikvCluster) bool

NeedForceUpgrade check if force upgrade is necessary

func NewPDMemberManager

func NewPDMemberManager(pdControl pdapi.PDControlInterface,
	setControl controller.StatefulSetControlInterface,
	svcControl controller.ServiceControlInterface,
	podControl controller.PodControlInterface,
	typedControl controller.TypedControlInterface,
	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 NewTiKVMemberManager

func NewTiKVMemberManager(
	pdControl pdapi.PDControlInterface,
	setControl controller.StatefulSetControlInterface,
	svcControl controller.ServiceControlInterface,
	typedControl controller.TypedControlInterface,
	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 PdPodName

func PdPodName(tcName string, ordinal int32) string

func RenderPDStartScript

func RenderPDStartScript(model *PDStartScriptModel) (string, error)

func RenderPumpStartScript

func RenderPumpStartScript(model *PumpStartScriptModel) (string, error)

func RenderTiDBInitInitStartScript

func RenderTiDBInitInitStartScript(model *TiDBInitInitStartScriptModel) (string, error)

func RenderTiDBInitStartScript

func RenderTiDBInitStartScript(model *TiDBInitStartScriptModel) (string, error)

func RenderTiDBStartScript

func RenderTiDBStartScript(model *TidbStartScriptModel) (string, error)

func RenderTiKVStartScript

func RenderTiKVStartScript(model *TiKVStartScriptModel) (string, error)

func SetStatefulSetLastAppliedConfigAnnotation

func SetStatefulSetLastAppliedConfigAnnotation(set *apps.StatefulSet) error

SetStatefulSetLastAppliedConfigAnnotation set last applied config to Statefulset's annotation

func Sha256Sum

func Sha256Sum(v interface{}) (string, error)

func TikvPodName

func TikvPodName(tcName string, ordinal int32) string

func UnmarshalTOML

func UnmarshalTOML(b []byte, obj interface{}) error

Types

type Failover

type Failover interface {
	Failover(*v1alpha1.TikvCluster) error
	Recover(*v1alpha1.TikvCluster)
}

Failover implements the logic for pd/tikv/tidb's failover and recovery.

func NewFakePDFailover

func NewFakePDFailover() Failover

NewFakePDFailover returns a fake Failover

func NewFakeTiKVFailover

func NewFakeTiKVFailover() Failover

NewFakeTiKVFailover returns a fake Failover

func NewPDFailover

NewPDFailover returns a pd Failover

func NewTiKVFailover

func NewTiKVFailover(tikvFailoverPeriod time.Duration, recorder record.EventRecorder) Failover

NewTiKVFailover returns a tikv Failover

type FakeDiscoveryManager

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

func NewFakeDiscoveryManger

func NewFakeDiscoveryManger() *FakeDiscoveryManager

func (*FakeDiscoveryManager) Reconcile

func (fdm *FakeDiscoveryManager) Reconcile(_ *v1alpha1.TikvCluster) error

func (*FakeDiscoveryManager) SetReconcileError

func (fdm *FakeDiscoveryManager) SetReconcileError(err error)

type FakeOrphanPodsCleaner

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

func NewFakeOrphanPodsCleaner

func NewFakeOrphanPodsCleaner() *FakeOrphanPodsCleaner

NewFakeOrphanPodsCleaner returns a fake orphan pods cleaner

func (*FakeOrphanPodsCleaner) Clean

func (*FakeOrphanPodsCleaner) SetnOrphanPodCleanerError

func (fpc *FakeOrphanPodsCleaner) SetnOrphanPodCleanerError(err error)

type FakePDMemberManager

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

func NewFakePDMemberManager

func NewFakePDMemberManager() *FakePDMemberManager

func (*FakePDMemberManager) SetSyncError

func (fpmm *FakePDMemberManager) SetSyncError(err error)

func (*FakePDMemberManager) Sync

type FakeTiKVMemberManager

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

func NewFakeTiKVMemberManager

func NewFakeTiKVMemberManager() *FakeTiKVMemberManager

func (*FakeTiKVMemberManager) SetSyncError

func (ftmm *FakeTiKVMemberManager) SetSyncError(err error)

func (*FakeTiKVMemberManager) Sync

type OrphanPodsCleaner

type OrphanPodsCleaner interface {
	Clean(*v1alpha1.TikvCluster) (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.

https://github.com/kubernetes/kubernetes/blob/84fe3db5cf58bf0fc8ff792b885465ceaf70a435/pkg/controller/statefulset/stateful_pod_control.go#L175-L199

func NewOrphanPodsCleaner

NewOrphanPodsCleaner returns a OrphanPodsCleaner

type PDDiscoveryManager

type PDDiscoveryManager interface {
	Reconcile(tc *v1alpha1.TikvCluster) error
}

func NewPDDiscoveryManager

func NewPDDiscoveryManager(typedControl controller.TypedControlInterface) PDDiscoveryManager

type PDStartScriptModel

type PDStartScriptModel struct {
	Scheme string
}

type PumpStartScriptModel

type PumpStartScriptModel struct {
	Scheme      string
	ClusterName string
	LogLevel    string
}

type Scaler

type Scaler interface {
	// Scale scales the cluster. It does nothing if scaling is not needed.
	Scale(tc *v1alpha1.TikvCluster, actual *apps.StatefulSet, desired *apps.StatefulSet) error
	// ScaleOut scales out the cluster
	ScaleOut(tc *v1alpha1.TikvCluster, actual *apps.StatefulSet, desired *apps.StatefulSet) error
	// ScaleIn scales in the cluster
	ScaleIn(tc *v1alpha1.TikvCluster, actual *apps.StatefulSet, desired *apps.StatefulSet) error
}

Scaler implements the logic for scaling out or scaling in the cluster.

func NewFakePDScaler

func NewFakePDScaler() Scaler

NewFakePDScaler returns a fake Scaler

func NewFakeTiKVScaler

func NewFakeTiKVScaler() Scaler

NewFakeTiKVScaler returns a fake tikv Scaler

func NewPDScaler

NewPDScaler returns a Scaler

func NewTiKVScaler

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 TiDBInitInitStartScriptModel

type TiDBInitInitStartScriptModel struct {
	ClusterName string
}

type TiDBInitStartScriptModel

type TiDBInitStartScriptModel struct {
	ClusterName string
	PermitHost  string
	PasswordSet bool
	InitSQL     bool
	TLS         bool
	CAPath      string
	CertPath    string
	KeyPath     string
}

type TiKVStartScriptModel

type TiKVStartScriptModel struct {
	Scheme string
}

type TidbStartScriptModel

type TidbStartScriptModel struct {
	ClusterName     string
	EnablePlugin    bool
	PluginDirectory string
	PluginList      string
}

type Upgrader

type Upgrader interface {
	// Upgrade upgrade the cluster
	Upgrade(*v1alpha1.TikvCluster, *apps.StatefulSet, *apps.StatefulSet) error
}

Upgrader implements the logic for upgrading the tidb cluster.

func NewFakePDUpgrader

func NewFakePDUpgrader() Upgrader

NewFakePDUpgrader returns a fakePDUpgrader

func NewFakeTiKVUpgrader

func NewFakeTiKVUpgrader() Upgrader

NewFakeTiKVUpgrader returns a fake tikv upgrader

func NewPDUpgrader

func NewPDUpgrader(pdControl pdapi.PDControlInterface,
	podControl controller.PodControlInterface,
	podLister corelisters.PodLister) Upgrader

NewPDUpgrader returns a pdUpgrader

func NewTiKVUpgrader

func NewTiKVUpgrader(pdControl pdapi.PDControlInterface,
	podControl controller.PodControlInterface,
	podLister corelisters.PodLister) Upgrader

NewTiKVUpgrader returns a tikv Upgrader

Jump to

Keyboard shortcuts

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