Documentation ¶
Index ¶
- Constants
- func GetHealthyMemberNames(memberHealth []healthCheck) []string
- func GetMemberHealth(ctx context.Context, clipool *EtcdClientPool, ...) memberHealth
- func GetMemberNameOrHost(member *etcdserverpb.Member) string
- func GetUnhealthyMemberNames(memberHealth []healthCheck) []string
- func GetUnstartedMemberNames(memberHealth []healthCheck) []string
- func HasStarted(member *etcdserverpb.Member) bool
- func IsClusterHealthy(memberHealth memberHealth) bool
- func IsQuorumFaultTolerant(memberHealth []healthCheck) bool
- func IsQuorumFaultTolerantErr(memberHealth []healthCheck) error
- func MinimumTolerableQuorum(members int) (int, error)
- type AllMemberLister
- type CachedMembers
- func (c *CachedMembers) HealthyMembers(ctx context.Context) ([]*etcdserverpb.Member, error)
- func (c *CachedMembers) HealthyVotingMembers(ctx context.Context) ([]*etcdserverpb.Member, error)
- func (c *CachedMembers) MemberHealth(ctx context.Context) (memberHealth, error)
- func (c *CachedMembers) MemberList(ctx context.Context) ([]*etcdserverpb.Member, error)
- func (c *CachedMembers) UnhealthyMembers(ctx context.Context) ([]*etcdserverpb.Member, error)
- func (c *CachedMembers) UnhealthyVotingMembers(ctx context.Context) ([]*etcdserverpb.Member, error)
- func (c *CachedMembers) VotingMemberList(ctx context.Context) ([]*etcdserverpb.Member, error)
- type ClientOption
- type ClientOptions
- type Defragment
- type EtcdClient
- type EtcdClientPool
- type FakeClientOption
- type FakeClientOptions
- type FakeMemberHealth
- type HealthyMemberLister
- type IsMemberHealthy
- type MemberAdder
- type MemberHealth
- type MemberLister
- type MemberPromoter
- type MemberRemover
- type MemberStatusChecker
- type Status
- type UnhealthyMemberLister
Constants ¶
const ( BootstrapIPAnnotationKey = "alpha.installer.openshift.io/etcd-bootstrap" DefaultDialTimeout = 15 * time.Second DefragDialTimeout = 60 * time.Second DefaultClientTimeout = 30 * time.Second )
const ( EtcdMemberStatusAvailable = "EtcdMemberAvailable" EtcdMemberStatusNotStarted = "EtcdMemberNotStarted" EtcdMemberStatusUnhealthy = "EtcdMemberUnhealthy" EtcdMemberStatusUnknown = "EtcdMemberUnknown" )
Variables ¶
This section is empty.
Functions ¶
func GetHealthyMemberNames ¶
func GetHealthyMemberNames(memberHealth []healthCheck) []string
GetHealthyMemberNames returns a list of healthy member names
func GetMemberHealth ¶
func GetMemberHealth(ctx context.Context, clipool *EtcdClientPool, etcdMembers []*etcdserverpb.Member) memberHealth
func GetMemberNameOrHost ¶
func GetMemberNameOrHost(member *etcdserverpb.Member) string
GetMemberNameOrHost If the member's name is not set, extract ip/hostname from peerURL. Useful with unstarted members.
func GetUnhealthyMemberNames ¶
func GetUnhealthyMemberNames(memberHealth []healthCheck) []string
GetUnhealthyMemberNames returns a list of unhealthy member names
func GetUnstartedMemberNames ¶
func GetUnstartedMemberNames(memberHealth []healthCheck) []string
GetUnstartedMemberNames returns a list of unstarted member names
func HasStarted ¶
func HasStarted(member *etcdserverpb.Member) bool
HasStarted return true if etcd member has started.
func IsClusterHealthy ¶
func IsClusterHealthy(memberHealth memberHealth) bool
func IsQuorumFaultTolerant ¶
func IsQuorumFaultTolerant(memberHealth []healthCheck) bool
IsQuorumFaultTolerant checks the current etcd cluster and returns true if the cluster can tolerate the loss of a single etcd member. Such loss is common during new static pod revision.
func IsQuorumFaultTolerantErr ¶
func IsQuorumFaultTolerantErr(memberHealth []healthCheck) error
IsQuorumFaultTolerantErr is the same as IsQuorumFaultTolerant but with an error return instead of the log
func MinimumTolerableQuorum ¶
Types ¶
type AllMemberLister ¶
type AllMemberLister interface { MemberLister HealthyMemberLister UnhealthyMemberLister MemberHealth }
func NewMemberCache ¶
func NewMemberCache(client EtcdClient) AllMemberLister
type CachedMembers ¶
type CachedMembers struct {
// contains filtered or unexported fields
}
func (*CachedMembers) HealthyMembers ¶
func (c *CachedMembers) HealthyMembers(ctx context.Context) ([]*etcdserverpb.Member, error)
func (*CachedMembers) HealthyVotingMembers ¶
func (c *CachedMembers) HealthyVotingMembers(ctx context.Context) ([]*etcdserverpb.Member, error)
func (*CachedMembers) MemberHealth ¶
func (c *CachedMembers) MemberHealth(ctx context.Context) (memberHealth, error)
func (*CachedMembers) MemberList ¶
func (c *CachedMembers) MemberList(ctx context.Context) ([]*etcdserverpb.Member, error)
func (*CachedMembers) UnhealthyMembers ¶
func (c *CachedMembers) UnhealthyMembers(ctx context.Context) ([]*etcdserverpb.Member, error)
func (*CachedMembers) UnhealthyVotingMembers ¶
func (c *CachedMembers) UnhealthyVotingMembers(ctx context.Context) ([]*etcdserverpb.Member, error)
func (*CachedMembers) VotingMemberList ¶
func (c *CachedMembers) VotingMemberList(ctx context.Context) ([]*etcdserverpb.Member, error)
type ClientOption ¶
type ClientOption func(*ClientOptions)
func WithDialTimeout ¶
func WithDialTimeout(timeout time.Duration) ClientOption
type ClientOptions ¶
type ClientOptions struct {
// contains filtered or unexported fields
}
type Defragment ¶
type Defragment interface {
Defragment(ctx context.Context, member *etcdserverpb.Member) (*clientv3.DefragmentResponse, error)
}
type EtcdClient ¶
type EtcdClient interface { Defragment MemberAdder MemberPromoter MemberHealth IsMemberHealthy MemberLister MemberRemover HealthyMemberLister UnhealthyMemberLister MemberStatusChecker Status GetMember(ctx context.Context, name string) (*etcdserverpb.Member, error) MemberUpdatePeerURL(ctx context.Context, id uint64, peerURL []string) error }
func NewEtcdClient ¶
func NewEtcdClient(kubeInformers v1helpers.KubeInformersForNamespaces, networkInformer configv1informers.NetworkInformer, eventRecorder events.Recorder) EtcdClient
func NewFakeEtcdClient ¶
func NewFakeEtcdClient(members []*etcdserverpb.Member, opts ...FakeClientOption) (EtcdClient, error)
type EtcdClientPool ¶
type EtcdClientPool struct {
// contains filtered or unexported fields
}
EtcdClientPool fulfills these requirements: * cache clients to avoid re-creating them all the time (TLS handshakes are expensive after all) * return an exclusively unused client, no other can acquire the same client at that time * health checking a client before using it (using list), return a new one if unhealthy and closing the old one * update endpoints, to be always up to date with the changes * return a used client to the pool, making it available to consume again
func NewEtcdClientPool ¶
func (*EtcdClientPool) Get ¶
func (p *EtcdClientPool) Get() (*clientv3.Client, error)
Get returns a client that can be used exclusively by the caller, the caller must not close the client but return it using Return. This is intentionally not a fast operation, Get will ensure the client returned will be healthy and retries on errors. If no client is available, this method will block intentionally to protect etcd from being overwhelmed by too many clients at once.
func (*EtcdClientPool) Return ¶
func (p *EtcdClientPool) Return(client *clientv3.Client)
Return will make the given client available for other callers through Get again. When the underlying pool is filled it will close the client instead of waiting for a free spot.
type FakeClientOption ¶
type FakeClientOption func(*FakeClientOptions)
func WithFakeClusterHealth ¶
func WithFakeClusterHealth(members *FakeMemberHealth) FakeClientOption
func WithFakeDefragErrors ¶
func WithFakeDefragErrors(errors []error) FakeClientOption
WithFakeDefragErrors configures each call to Defrag to consume one error from the given slice
func WithFakeStatus ¶
func WithFakeStatus(status []*clientv3.StatusResponse) FakeClientOption
type FakeClientOptions ¶
type FakeClientOptions struct {
// contains filtered or unexported fields
}
type FakeMemberHealth ¶
type HealthyMemberLister ¶
type HealthyMemberLister interface { // HealthyMembers lists all healthy members in a cluster HealthyMembers(ctx context.Context) ([]*etcdserverpb.Member, error) // HealthyVotingMembers lists all non learner healthy members in a cluster HealthyVotingMembers(ctx context.Context) ([]*etcdserverpb.Member, error) }
type IsMemberHealthy ¶
type MemberAdder ¶
type MemberHealth ¶
type MemberLister ¶
type MemberLister interface { // MemberList lists all members in a cluster MemberList(ctx context.Context) ([]*etcdserverpb.Member, error) // VotingMemberList lists all non learner members in a cluster VotingMemberList(ctx context.Context) ([]*etcdserverpb.Member, error) }
type MemberPromoter ¶
type MemberPromoter interface {
MemberPromote(ctx context.Context, member *etcdserverpb.Member) error
}
type MemberRemover ¶
type MemberStatusChecker ¶
type MemberStatusChecker interface {
MemberStatus(ctx context.Context, member *etcdserverpb.Member) string
}
type UnhealthyMemberLister ¶
type UnhealthyMemberLister interface { // UnhealthyMembers lists all unhealthy members in a cluster UnhealthyMembers(ctx context.Context) ([]*etcdserverpb.Member, error) // UnhealthyVotingMembers lists all non learner unhealthy members in a cluster UnhealthyVotingMembers(ctx context.Context) ([]*etcdserverpb.Member, error) }