Skip to content

Commit

Permalink
optimize observer recover logic
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-sun-star committed Apr 23, 2024
1 parent 97229d3 commit e8b1174
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
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 e8b1174

Please sign in to comment.