Documentation ¶
Index ¶
- Constants
- func GetTLSConfig(kubeCli kubernetes.Interface, namespace Namespace, tcName string, ...) (*tls.Config, error)
- func PdClientURL(namespace Namespace, clusterName string, scheme string) string
- type Action
- type ActionType
- type FakePDClient
- func (pc *FakePDClient) AddReaction(actionType ActionType, reaction Reaction)
- func (pc *FakePDClient) BeginEvictLeader(storeID uint64) error
- func (pc *FakePDClient) DeleteMember(name string) error
- func (pc *FakePDClient) DeleteMemberByID(id uint64) error
- func (pc *FakePDClient) DeleteStore(id uint64) error
- func (pc *FakePDClient) EndEvictLeader(storeID uint64) error
- func (pc *FakePDClient) GetCluster() (*metapb.Cluster, error)
- func (pc *FakePDClient) GetConfig() (*v1alpha1.PDConfig, error)
- func (pc *FakePDClient) GetEvictLeaderSchedulers() ([]string, error)
- func (pc *FakePDClient) GetHealth() (*HealthInfo, error)
- func (pc *FakePDClient) GetMembers() (*MembersInfo, error)
- func (pc *FakePDClient) GetPDLeader() (*pdpb.Member, error)
- func (pc *FakePDClient) GetStore(id uint64) (*StoreInfo, error)
- func (pc *FakePDClient) GetStores() (*StoresInfo, error)
- func (pc *FakePDClient) GetTombStoneStores() (*StoresInfo, error)
- func (pc *FakePDClient) SetStoreLabels(storeID uint64, labels map[string]string) (bool, error)
- func (pc *FakePDClient) TransferPDLeader(memberName string) error
- type FakePDControl
- type HealthInfo
- type MemberHealth
- type MembersInfo
- type MetaStore
- type Namespace
- type NotFoundReaction
- type PDClient
- type PDControlInterface
- type Reaction
- type StoreInfo
- type StoreStatus
- type StoresInfo
Constants ¶
const (
DefaultTimeout = 5 * time.Second
)
Variables ¶
This section is empty.
Functions ¶
func GetTLSConfig ¶ added in v1.1.0
func GetTLSConfig(kubeCli kubernetes.Interface, namespace Namespace, tcName string, caCert []byte) (*tls.Config, error)
GetTLSConfig returns *tls.Config for given TiDB cluster. It loads in-cluster root ca if caCert is empty.
Types ¶
type ActionType ¶
type ActionType string
const ( GetHealthActionType ActionType = "GetHealth" GetConfigActionType ActionType = "GetConfig" GetClusterActionType ActionType = "GetCluster" GetMembersActionType ActionType = "GetMembers" GetStoresActionType ActionType = "GetStores" GetTombStoneStoresActionType ActionType = "GetTombStoneStores" GetStoreActionType ActionType = "GetStore" DeleteStoreActionType ActionType = "DeleteStore" DeleteMemberByIDActionType ActionType = "DeleteMemberByID" DeleteMemberActionType ActionType = "DeleteMember " SetStoreLabelsActionType ActionType = "SetStoreLabels" BeginEvictLeaderActionType ActionType = "BeginEvictLeader" EndEvictLeaderActionType ActionType = "EndEvictLeader" GetEvictLeaderSchedulersActionType ActionType = "GetEvictLeaderSchedulers" GetPDLeaderActionType ActionType = "GetPDLeader" TransferPDLeaderActionType ActionType = "TransferPDLeader" )
type FakePDClient ¶
type FakePDClient struct {
// contains filtered or unexported fields
}
func NewFakePDClient ¶
func NewFakePDClient() *FakePDClient
func (*FakePDClient) AddReaction ¶
func (pc *FakePDClient) AddReaction(actionType ActionType, reaction Reaction)
func (*FakePDClient) BeginEvictLeader ¶
func (pc *FakePDClient) BeginEvictLeader(storeID uint64) error
func (*FakePDClient) DeleteMember ¶
func (pc *FakePDClient) DeleteMember(name string) error
func (*FakePDClient) DeleteMemberByID ¶
func (pc *FakePDClient) DeleteMemberByID(id uint64) error
func (*FakePDClient) DeleteStore ¶
func (pc *FakePDClient) DeleteStore(id uint64) error
func (*FakePDClient) EndEvictLeader ¶
func (pc *FakePDClient) EndEvictLeader(storeID uint64) error
func (*FakePDClient) GetCluster ¶
func (pc *FakePDClient) GetCluster() (*metapb.Cluster, error)
func (*FakePDClient) GetEvictLeaderSchedulers ¶
func (pc *FakePDClient) GetEvictLeaderSchedulers() ([]string, error)
func (*FakePDClient) GetHealth ¶
func (pc *FakePDClient) GetHealth() (*HealthInfo, error)
func (*FakePDClient) GetMembers ¶
func (pc *FakePDClient) GetMembers() (*MembersInfo, error)
func (*FakePDClient) GetPDLeader ¶
func (pc *FakePDClient) GetPDLeader() (*pdpb.Member, error)
func (*FakePDClient) GetStores ¶
func (pc *FakePDClient) GetStores() (*StoresInfo, error)
func (*FakePDClient) GetTombStoneStores ¶
func (pc *FakePDClient) GetTombStoneStores() (*StoresInfo, error)
func (*FakePDClient) SetStoreLabels ¶
SetStoreLabels sets TiKV labels
func (*FakePDClient) TransferPDLeader ¶
func (pc *FakePDClient) TransferPDLeader(memberName string) error
type FakePDControl ¶
type FakePDControl struct {
// contains filtered or unexported fields
}
func NewFakePDControl ¶
func NewFakePDControl(kubeCli kubernetes.Interface) *FakePDControl
func (*FakePDControl) GetPDClient ¶
GetPDClient provides a PDClient of real pd cluster,if the PDClient not existing, it will create new one.
func (*FakePDControl) SetPDClient ¶
func (fpc *FakePDControl) SetPDClient(namespace Namespace, tcName string, pdclient PDClient)
type HealthInfo ¶
type HealthInfo struct {
Healths []MemberHealth
}
HealthInfo define PD's healthy info
type MemberHealth ¶
type MemberHealth struct { Name string `json:"name"` MemberID uint64 `json:"member_id"` ClientUrls []string `json:"client_urls"` Health bool `json:"health"` }
MemberHealth define a pd member's healthy info
type MembersInfo ¶
type MembersInfo struct { Header *pdpb.ResponseHeader `json:"header,omitempty"` Members []*pdpb.Member `json:"members,omitempty"` Leader *pdpb.Member `json:"leader,omitempty"` EtcdLeader *pdpb.Member `json:"etcd_leader,omitempty"` }
MembersInfo is PD members info returned from PD RESTful interface type Members map[string][]*pdpb.Member
type NotFoundReaction ¶
type NotFoundReaction struct {
// contains filtered or unexported fields
}
func (*NotFoundReaction) Error ¶
func (nfr *NotFoundReaction) Error() string
type PDClient ¶
type PDClient interface { // GetHealth returns the PD's health info GetHealth() (*HealthInfo, error) // GetConfig returns PD's config GetConfig() (*v1alpha1.PDConfig, error) // GetCluster returns used when syncing pod labels. GetCluster() (*metapb.Cluster, error) // GetMembers returns all PD members from cluster GetMembers() (*MembersInfo, error) // GetStores lists all TiKV stores from cluster GetStores() (*StoresInfo, error) // GetTombStoneStores lists all tombstone stores from cluster GetTombStoneStores() (*StoresInfo, error) // GetStore gets a TiKV store for a specific store id from cluster GetStore(storeID uint64) (*StoreInfo, error) // storeLabelsEqualNodeLabels compares store labels with node labels // for historic reasons, PD stores TiKV labels as []*StoreLabel which is a key-value pair slice SetStoreLabels(storeID uint64, labels map[string]string) (bool, error) // DeleteStore deletes a TiKV store from cluster DeleteStore(storeID uint64) error // DeleteMember deletes a PD member from cluster DeleteMember(name string) error // DeleteMemberByID deletes a PD member from cluster DeleteMemberByID(memberID uint64) error // BeginEvictLeader initiates leader eviction for a storeID. // This is used when upgrading a pod. BeginEvictLeader(storeID uint64) error // EndEvictLeader is used at the end of pod upgrade. EndEvictLeader(storeID uint64) error // GetEvictLeaderSchedulers gets schedulers of evict leader GetEvictLeaderSchedulers() ([]string, error) // GetPDLeader returns pd leader GetPDLeader() (*pdpb.Member, error) // TransferPDLeader transfers pd leader to specified member TransferPDLeader(name string) error }
PDClient provides pd server's api
type PDControlInterface ¶
type PDControlInterface interface { // GetPDClient provides PDClient of the tidb cluster. GetPDClient(Namespace, string, bool) PDClient }
PDControlInterface is an interface that knows how to manage and get tidb cluster's PD client
func NewDefaultPDControl ¶
func NewDefaultPDControl(kubeCli kubernetes.Interface) PDControlInterface
NewDefaultPDControl returns a defaultPDControl instance
type StoreInfo ¶
type StoreInfo struct { Store *MetaStore `json:"store"` Status *StoreStatus `json:"status"` }
StoreInfo is a single store info returned from PD RESTful interface
type StoreStatus ¶
type StoreStatus struct { Capacity typeutil.ByteSize `json:"capacity"` Available typeutil.ByteSize `json:"available"` LeaderCount int `json:"leader_count"` RegionCount int `json:"region_count"` SendingSnapCount uint32 `json:"sending_snap_count"` ReceivingSnapCount uint32 `json:"receiving_snap_count"` ApplyingSnapCount uint32 `json:"applying_snap_count"` IsBusy bool `json:"is_busy"` StartTS time.Time `json:"start_ts"` LastHeartbeatTS time.Time `json:"last_heartbeat_ts"` Uptime typeutil.Duration `json:"uptime"` }
StoreStatus is TiKV store status returned from PD RESTful interface
type StoresInfo ¶
StoresInfo is stores info returned from PD RESTful interface