Documentation
¶
Index ¶
- Constants
- Variables
- func AckRecovery(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, ...) error
- func AddPeer(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, peer string) error
- func BeginDowntime(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, host string, ...) error
- func ConfigMap(cr *apiv1.PerconaServerMySQL) (*corev1.ConfigMap, error)
- func ConfigMapData(cr *apiv1.PerconaServerMySQL) (string, error)
- func ConfigMapName(cr *apiv1.PerconaServerMySQL) string
- func Discover(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, host string, ...) error
- func EndDowntime(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, host string, ...) error
- func EnsureNodeIsPrimary(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, ...) (err error)
- func ExistingNodes(cmap *corev1.ConfigMap) ([]string, error)
- func FQDN(cr *apiv1.PerconaServerMySQL, idx int) string
- func ForceMasterTakeover(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, ...) error
- func ForgetInstance(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, host string, ...) error
- func GetReadyPod(ctx context.Context, cl client.Client, cluster *apiv1.PerconaServerMySQL) (*corev1.Pod, error)
- func IsMasterFailover(analysis string) bool
- func IsPlannedTakeover(command string) bool
- func Labels(cr *apiv1.PerconaServerMySQL) map[string]string
- func LiveClaims(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod) ([]string, error)
- func MatchLabels(cr *apiv1.PerconaServerMySQL) map[string]string
- func Name(cr *apiv1.PerconaServerMySQL) string
- func NamespacedName(cr *apiv1.PerconaServerMySQL) types.NamespacedName
- func PodName(cr *apiv1.PerconaServerMySQL, idx int) string
- func PodService(cr *apiv1.PerconaServerMySQL, t corev1.ServiceType, podName string) *corev1.Service
- func RBAC(cr *apiv1.PerconaServerMySQL) (*rbacv1.Role, *rbacv1.RoleBinding, *corev1.ServiceAccount)
- func RaftNodes(cr *apiv1.PerconaServerMySQL) []string
- func RaftState(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod) (string, error)
- func RegisterCandidate(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, host string, ...) error
- func RemovePeer(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, peer string) error
- func ResolveCluster(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, ...) (string, error)
- func Service(cr *apiv1.PerconaServerMySQL) *corev1.Service
- func ServiceName(cr *apiv1.PerconaServerMySQL) string
- func SetWriteable(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, host string, ...) error
- func StartReplication(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, host string, ...) error
- func StatefulSet(cr *apiv1.PerconaServerMySQL, initImage, configHash, tlsHash string) *appsv1.StatefulSet
- func StopReplication(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, host string, ...) error
- func SwitchoverCatchUp(cr *apiv1.PerconaServerMySQL) (time.Duration, error)
- func SwitchoverDowntime(catchUp time.Duration) int
- type BinlogCoordinates
- type Component
- func (c *Component) Labels() map[string]string
- func (c *Component) MatchLabels() map[string]string
- func (c *Component) Name() string
- func (c *Component) Object(ctx context.Context, cl client.Client) (client.Object, error)
- func (c *Component) PerconaServerMySQL() *apiv1.PerconaServerMySQL
- func (c *Component) PodSpec() *apiv1.PodSpec
- type Exposer
- type Instance
- func Cluster(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, ...) ([]*Instance, error)
- func ClusterPrimary(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, ...) (*Instance, error)
- func GetInstance(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, host string, ...) (*Instance, error)
- func RefreshInstance(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, host string, ...) (*Instance, error)
- func ReplicasOf(instances []*Instance, host string) []*Instance
- type InstanceKey
- type Recovery
Constants ¶
const ( PromotionRulePrefer = "prefer" PromotionRuleNeutral = "neutral" PromotionRuleMustNot = "must_not" )
const ( DowntimeOwner = "percona-server-mysql-operator" DowntimeReasonSwitchover = "graceful-switchover" DowntimeReasonForcePromote = "force-promote" // DowntimeReasonLostInRecovery is the downtime orchestrator puts on the // failed primary at the end of every master recovery, for a year, whether // it promoted a replica or not. Orchestrator does not recover a downtimed // instance, so after a failed promotion it never retries DowntimeReasonLostInRecovery = "lost-in-recovery" )
const ( AppName = "orchestrator" // HandlerStateDir is where orc-handler keeps the marks a failover leaves // between hook runs. It sits on the pod's config emptyDir, next to // orchestrator's own database, so a container restart keeps both or // neither. HandlerStateDir = configMountPath + "/orc-handler" CredsMountPath = "/etc/orchestrator/orchestrator-users-secret" )
const ProblemReplicationLag = "replication_lag"
ProblemReplicationLag is reported for a replica lagging more than ReasonableReplicationLagSeconds.
const RaftStateLeader = "Leader"
const RecoveryClaimIdle = 5 * time.Minute
RecoveryClaimIdle is how long the pre-failover hook's claim on a source outlives its last heartbeat. A claim idle for longer belongs to a recovery whose hook is gone, and both the hook's gate and the operator treat that recovery as over.
Variables ¶
var ( ErrEmptyResponse = errors.New("empty response") ErrUnableToGetClusterName = errors.New("unable to determine cluster name") ErrBadConn = errors.New("bad connection") ErrNoSuchHost = errors.New("mysql host not found") ErrTimeout = errors.New("timeout") ErrContainerNotFound = errors.New("orchestrator container not found") // ErrRecoveryNotAttempted is orchestrator turning a takeover away because // another recovery of the same instance holds its place in the audit ErrRecoveryNotAttempted = errors.New("recovery not attempted") // ErrInstanceUnreachable is orchestrator's own answer that it could not // read the instance when asked to refresh it. ErrInstanceUnreachable = errors.New("instance unreachable") )
var ErrSplitTopology = errors.New("orchestrator sees more than one live cluster")
Functions ¶
func AckRecovery ¶ added in v1.3.0
func AckRecovery(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, uid, comment string) error
AckRecovery acknowledges the recovery orchestrator identifies by uid, which ends the active period it holds on the cluster and on the instance it promoted. Until then orchestrator starts no other recovery for either. The comment is what the audit shows as the reason.
func BeginDowntime ¶ added in v0.12.0
func ConfigMap ¶ added in v0.2.0
func ConfigMap(cr *apiv1.PerconaServerMySQL) (*corev1.ConfigMap, error)
func ConfigMapData ¶ added in v0.2.0
func ConfigMapData(cr *apiv1.PerconaServerMySQL) (string, error)
func ConfigMapName ¶ added in v0.2.0
func ConfigMapName(cr *apiv1.PerconaServerMySQL) string
func EndDowntime ¶ added in v0.12.0
func EnsureNodeIsPrimary ¶ added in v0.3.0
func ForceMasterTakeover ¶ added in v1.3.0
func ForceMasterTakeover(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, clusterHint, host string, port int32) error
ForceMasterTakeover promotes host even though orchestrator sees no reason to. It is the break-glass path for a cluster left without a writable primary because the pre-failover hook could not recover the transactions stranded on the dead one, so it gives those transactions up.
func ForgetInstance ¶ added in v0.8.0
func GetReadyPod ¶ added in v0.12.0
func IsMasterFailover ¶ added in v1.3.0
func IsPlannedTakeover ¶ added in v1.3.0
func Labels ¶
func Labels(cr *apiv1.PerconaServerMySQL) map[string]string
Labels returns labels of orchestrator
func LiveClaims ¶ added in v1.3.0
LiveClaims returns the recoveries whose pre-failover hook is still in flight on the orchestrator in pod.
func MatchLabels ¶
func MatchLabels(cr *apiv1.PerconaServerMySQL) map[string]string
func NamespacedName ¶
func NamespacedName(cr *apiv1.PerconaServerMySQL) types.NamespacedName
func PodService ¶ added in v0.2.0
func PodService(cr *apiv1.PerconaServerMySQL, t corev1.ServiceType, podName string) *corev1.Service
func RBAC ¶ added in v0.8.0
func RBAC(cr *apiv1.PerconaServerMySQL) (*rbacv1.Role, *rbacv1.RoleBinding, *corev1.ServiceAccount)
func RaftNodes ¶ added in v0.2.0
func RaftNodes(cr *apiv1.PerconaServerMySQL) []string
func RegisterCandidate ¶ added in v1.3.0
func RegisterCandidate(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, host string, port int32, promotionRule string) error
RegisterCandidate sets the promotion rule orchestrator applies to an instance when it picks a replica to promote. The registration expires on its own after CandidateInstanceExpireMinutes.
func RemovePeer ¶ added in v0.2.0
func ResolveCluster ¶ added in v1.3.0
func ResolveCluster(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, clusterHint string) (string, error)
ResolveCluster returns the name of the one cluster the orchestrator of this cluster holds live instances of. The alias does not do: every primary claims it through DetectClusterAliasQuery, so a primary left outside the topology takes the alias over and a lookup by it lands on either cluster.
func ServiceName ¶
func ServiceName(cr *apiv1.PerconaServerMySQL) string
func SetWriteable ¶ added in v0.8.0
func StartReplication ¶
func StatefulSet ¶
func StatefulSet(cr *apiv1.PerconaServerMySQL, initImage, configHash, tlsHash string) *appsv1.StatefulSet
func StopReplication ¶
func SwitchoverCatchUp ¶ added in v1.3.0
func SwitchoverCatchUp(cr *apiv1.PerconaServerMySQL) (time.Duration, error)
SwitchoverCatchUp is the effective ReasonableMaintenanceReplicationLagSeconds. Orchestrator refuses a graceful takeover to a candidate lagging more than this, and waits at most this long for the candidate after freezing the primary.
func SwitchoverDowntime ¶ added in v1.3.0
SwitchoverDowntime is how long the old primary is kept downtimed during a graceful switchover, derived from the catch-up wait so the two cannot drift apart.
Types ¶
type BinlogCoordinates ¶ added in v1.3.0
type Component ¶ added in v0.12.0
type Component apiv1.PerconaServerMySQL
func (*Component) MatchLabels ¶ added in v0.12.0
func (*Component) PerconaServerMySQL ¶ added in v0.12.0
func (c *Component) PerconaServerMySQL() *apiv1.PerconaServerMySQL
type Exposer ¶ added in v0.2.0
type Exposer apiv1.PerconaServerMySQL
func (*Exposer) MatchLabels ¶ added in v0.12.0
func (*Exposer) SaveOldMeta ¶ added in v0.4.0
type Instance ¶
type Instance struct {
Key InstanceKey `json:"Key"`
Alias string `json:"InstanceAlias"`
ClusterName string `json:"ClusterName"`
MasterKey InstanceKey `json:"MasterKey"`
Replicas []InstanceKey `json:"Replicas"`
ReadOnly bool `json:"ReadOnly"`
IsLastCheckValid bool `json:"IsLastCheckValid"`
Problems []string `json:"Problems"`
IsDowntimed bool `json:"IsDowntimed"`
DowntimeReason string `json:"DowntimeReason"`
DowntimeOwner string `json:"DowntimeOwner"`
DowntimeEndTimestamp string `json:"DowntimeEndTimestamp"`
ElapsedDowntime time.Duration `json:"ElapsedDowntime"`
ExecBinlogCoordinates BinlogCoordinates `json:"ExecBinlogCoordinates"`
ExecutedGtidSet string `json:"ExecutedGtidSet"`
ReplicationLagSeconds sql.NullInt64 `json:"ReplicationLagSeconds"`
}
func ClusterPrimary ¶
func GetInstance ¶ added in v1.2.0
func RefreshInstance ¶ added in v1.3.0
func RefreshInstance(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, host string, port int) (*Instance, error)
RefreshInstance has orchestrator read the instance now rather than answer from its last poll. It fails when orchestrator can't reach the instance.
func ReplicasOf ¶ added in v1.3.0
ReplicasOf returns the instances replicating from host.
type InstanceKey ¶
func BestCandidate ¶ added in v1.3.0
func BestCandidate(instances []*Instance) (InstanceKey, bool)
BestCandidate returns the replica best suited for promotion, whichever instance it currently replicates from. It is the pick for a promotion forced by hand, where the old primary may be gone from the topology already.
func MostUpToDate ¶ added in v1.3.0
func MostUpToDate(replicas []*Instance) InstanceKey
MostUpToDate returns the replica with the least to catch up on.
type Recovery ¶ added in v1.3.0
type Recovery struct {
UID string `json:"UID"`
Analysis struct {
FailedKey InstanceKey `json:"AnalyzedInstanceKey"`
Analysis string `json:"Analysis"`
CommandHint string `json:"CommandHint"`
} `json:"AnalysisEntry"`
IsActive bool `json:"IsActive"`
IsSuccessful bool `json:"IsSuccessful"`
Acknowledged bool `json:"Acknowledged"`
RecoveryEndTimestamp string `json:"RecoveryEndTimestamp"`
}
Recovery is an entry of orchestrator's recovery audit.
func UnacknowledgedRecoveries ¶ added in v1.3.0
func UnacknowledgedRecoveries(ctx context.Context, cliCmd clientcmd.Client, pod *corev1.Pod, clusterHint string) ([]Recovery, error)
UnacknowledgedRecoveries returns the cluster's recoveries nobody has acknowledged yet, newest first.