Skip to content

update upgrade task status timestamp safely #5317

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

Merged
merged 2 commits into from
May 12, 2025
Merged
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
14 changes: 13 additions & 1 deletion pkg/tasks/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func StartTicker(taskID string, finishedChan <-chan struct{}) {
for {
select {
case <-time.After(time.Second * 2):
if err := UpdateTaskStatusTimestamp(taskID); err != nil {
if err := updateTaskStatusTimestampSafely(taskID); err != nil {
logger.Error(err)
}
case <-finishedChan:
Expand All @@ -63,6 +63,18 @@ func StartTicker(taskID string, finishedChan <-chan struct{}) {
}
}

func updateTaskStatusTimestampSafely(taskID string) (finalError error) {
defer func() {
if r := recover(); r != nil {
finalError = fmt.Errorf("recovered from panic safely while updating task (%s) status timestamp: %v", taskID, r)
}
}()
if err := UpdateTaskStatusTimestamp(taskID); err != nil {
return err
}
return nil
}

func SetTaskStatus(id string, message string, status string) error {
db := persistence.MustGetDBSession()

Expand Down
Loading