Skip to content

Commit

Permalink
Fix optimize observer recover logic (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-sun-star authored Apr 23, 2024
1 parent 97229d3 commit 97d0c4b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
1 change: 0 additions & 1 deletion internal/resource/observer/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const (
fDeleteOBServerFinalizer ttypes.FlowName = "delete observer finalizer"
fUpgradeOBServer ttypes.FlowName = "upgrade observer"
fRecoverOBServer ttypes.FlowName = "recover observer"
fAddServerInOB ttypes.FlowName = "add observer in ob"
fAnnotateOBServerPod ttypes.FlowName = "annotate observer pod"
fScaleUpOBServer ttypes.FlowName = "scale up observer"
fExpandPVC ttypes.FlowName = "expand pvc for observer"
Expand Down
12 changes: 1 addition & 11 deletions internal/resource/observer/observer_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func genRecoverOBServerFlow(_ *OBServerManager) *tasktypes.TaskFlow {
return &tasktypes.TaskFlow{
OperationContext: &tasktypes.OperationContext{
Name: fRecoverOBServer,
Tasks: []tasktypes.TaskName{tCreateOBPod, tWaitOBServerReady, tWaitOBServerActiveInCluster},
Tasks: []tasktypes.TaskName{tCreateOBPod, tWaitOBServerReady, tAddServer, tWaitOBServerActiveInCluster},
TargetStatus: serverstatus.Running,
OnFailure: tasktypes.FailureRule{
Strategy: strategy.RetryFromCurrent,
Expand All @@ -84,16 +84,6 @@ func genRecoverOBServerFlow(_ *OBServerManager) *tasktypes.TaskFlow {
}
}

func genAddServerInOBFlow(_ *OBServerManager) *tasktypes.TaskFlow {
return &tasktypes.TaskFlow{
OperationContext: &tasktypes.OperationContext{
Name: fAddServerInOB,
Tasks: []tasktypes.TaskName{tAddServer, tWaitOBServerActiveInCluster},
TargetStatus: serverstatus.Running,
},
}
}

func genAnnotateOBServerPodFlow(_ *OBServerManager) *tasktypes.TaskFlow {
return &tasktypes.TaskFlow{
OperationContext: &tasktypes.OperationContext{
Expand Down
9 changes: 1 addition & 8 deletions internal/resource/observer/observer_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,7 @@ func (m *OBServerManager) UpdateStatus() error {
// 1. Check status of observer in OB database
if m.OBServer.Status.Status == serverstatus.Running {
m.Logger.V(oceanbaseconst.LogLevelDebug).Info("Check observer in obcluster")
observer, err := m.getCurrentOBServerFromOB()
if err != nil {
m.Logger.V(oceanbaseconst.LogLevelDebug).Info("Get observer failed, check next time")
} else if observer == nil {
m.OBServer.Status.Status = serverstatus.AddServer
} else if mode, exist := resourceutils.GetAnnotationField(m.OBServer, oceanbaseconst.AnnotationsMode); exist && mode == oceanbaseconst.ModeStandalone {
if mode, exist := resourceutils.GetAnnotationField(m.OBServer, oceanbaseconst.AnnotationsMode); exist && mode == oceanbaseconst.ModeStandalone {
if pod.Spec.Containers[0].Resources.Limits.Cpu().Cmp(m.OBServer.Spec.OBServerTemplate.Resource.Cpu) != 0 ||
pod.Spec.Containers[0].Resources.Limits.Memory().Cmp(m.OBServer.Spec.OBServerTemplate.Resource.Memory) != 0 {
m.OBServer.Status.Status = serverstatus.ScaleUp
Expand Down Expand Up @@ -228,8 +223,6 @@ func (m *OBServerManager) GetTaskFlow() (*tasktypes.TaskFlow, error) {
taskFlow = genRecoverOBServerFlow(m)
case serverstatus.Annotate:
taskFlow = genAnnotateOBServerPodFlow(m)
case serverstatus.AddServer:
taskFlow = genAddServerInOBFlow(m)
case serverstatus.ScaleUp:
taskFlow = genScaleUpOBServerFlow(m)
case serverstatus.ExpandPVC:
Expand Down

0 comments on commit 97d0c4b

Please sign in to comment.