Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve lorry performance #6002

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lorry/binding/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ func (ops *BaseOperations) GetRoleOps(ctx context.Context, req *ProbeRequest, re
// roleValidate is used to filter the internal roles and decrease the number
// of report events to reduce the possibility of event conflicts.
func (ops *BaseOperations) roleValidate(role string) (bool, string) {
if role == "" {
return false, "role is none"
}

// do not validate them when db roles setting is missing
if len(ops.DBRoles) == 0 {
return true, ""
Expand Down
8 changes: 4 additions & 4 deletions lorry/dcs/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,22 @@ func (store *KubernetesStore) GetCluster() (*Cluster, error) {

members, err := store.GetMembers()
if err != nil {
store.logger.Error(err, "get members error")
return nil, err
}

leader, err := store.GetLeader()
if err != nil {
store.logger.Error(err, "get leader error")
store.logger.Info("get leader failed", "error", err)
}

switchover, err := store.GetSwitchover()
if err != nil {
store.logger.Error(err, "get switchover error")
store.logger.Info("get switchover failed", "error", err)
}

haConfig, err := store.GetHaConfig()
if err != nil {
store.logger.Error(err, "get HaConfig error")
store.logger.Info("get haconfig failed", "error", err)
}

cluster := &Cluster{
Expand Down
9 changes: 5 additions & 4 deletions lorry/highavailability/ha.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func GetHa() *Ha {
func (ha *Ha) RunCycle() {
cluster, err := ha.dcs.GetCluster()
if err != nil {
ha.logger.Error(err, "Get Cluster err")
ha.logger.Error(err, "Get Cluster failed")
return
}

Expand Down Expand Up @@ -212,9 +212,10 @@ func (ha *Ha) RunCycle() {
func (ha *Ha) Start() {
ha.logger.Info("HA starting")
cluster, err := ha.dcs.GetCluster()
if cluster == nil {
ha.logger.Error(err, "Get Cluster error, so HA exists.", "cluster-name", ha.dcs.GetClusterName())
return
for cluster == nil {
ha.logger.Error(err, "Get Cluster failed.", "cluster-name", ha.dcs.GetClusterName())
time.Sleep(10 * time.Second)
cluster, err = ha.dcs.GetCluster()
}

isPodReady, err := ha.IsPodReady()
Expand Down
3 changes: 2 additions & 1 deletion lorry/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ func IsHAAvailable(characterType, workloadType string) bool {
case "mongodb":
return true
case "mysql":
if strings.EqualFold(workloadType, Replication) || strings.EqualFold(workloadType, Consensus) {
// if strings.EqualFold(workloadType, Replication) || strings.EqualFold(workloadType, Consensus) {
if strings.EqualFold(workloadType, Replication) {
return true
}
case "postgresql":
Expand Down