Skip to content

Commit

Permalink
fix(evpn): create checkStatus func in task manager
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitrios Markou <dimitrios.markou@ericsson.com>
  • Loading branch information
mardim91 committed Sep 20, 2024
1 parent 3154210 commit 7a53660
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions pkg/infradb/taskmanager/taskmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ func (t *TaskManager) ReplayFinished() {
}

// processTasks processes the task
//
//gocognit:ignore
func (t *TaskManager) processTasks() {
var taskStatus *TaskStatus

Expand Down Expand Up @@ -163,19 +161,9 @@ func (t *TaskManager) processTasks() {
}

// This check is needed in order to move to the next task if the status channel has timed out or we need to drop the task in case that
// the task of the object is referring to an old already updated object or the object is no longer in the database (has been deleted).
if taskStatus == nil {
log.Println("processTasks(): Move to the next Task in the queue")
break loopTwo
}

if taskStatus.dropTask {
if taskStatus.component.Replay {
log.Println("processTasks(): Wait for the replay DB procedure to finish and move to the next Task in the queue")
<-t.replayChan
log.Println("processTasks(): Replay has finished. Continuing processing tasks")
}

// the task of the object is referring to an old already updated object or the object is no longer in the database (has been deleted)
// or a replay procedure has been requested
if t.checkStatus(taskStatus) {
log.Println("processTasks(): Move to the next Task in the queue")
break loopTwo
}
Expand All @@ -197,3 +185,22 @@ func (t *TaskManager) processTasks() {
}
}
}

// checkStatus checks if the taskStatus is nill or if the current Task
// should be dropped or if a replay procedure has been requested
func (t *TaskManager) checkStatus(taskStatus *TaskStatus) bool {
if taskStatus == nil {
return true
}

if taskStatus.dropTask {
if taskStatus.component.Replay {
log.Println("checkStatus(): Wait for the replay DB procedure to finish and move to the next Task in the queue")
<-t.replayChan
log.Println("checkStatus(): Replay has finished. Continuing processing tasks")
}
return true
}

return false
}

0 comments on commit 7a53660

Please sign in to comment.