diff --git a/pkg/task/manager.go b/pkg/task/manager.go index 673f1a587df..cd7c69a225e 100644 --- a/pkg/task/manager.go +++ b/pkg/task/manager.go @@ -122,6 +122,10 @@ func (tm *Manager[K]) ClearDone() { tm.RemoveByStates(SUCCEEDED, CANCELED, ERRORED) } +func (tm *Manager[K]) ClearSucceeded() { + tm.RemoveByStates(SUCCEEDED) +} + func (tm *Manager[K]) RawTasks() *generic_sync.MapOf[K, *Task[K]] { return &tm.tasks } diff --git a/server/handles/task.go b/server/handles/task.go index 08f3a4b4c66..d76bb586e27 100644 --- a/server/handles/task.go +++ b/server/handles/task.go @@ -92,10 +92,27 @@ func taskRoute[K comparable](g *gin.RouterGroup, manager *task.Manager[K], k2Str common.SuccessResp(c) } }) + g.POST("/retry", func(c *gin.Context) { + tid := c.Query("tid") + id, err := str2K(tid) + if err != nil { + common.ErrorResp(c, err, 400) + return + } + if err := manager.Retry(id); err != nil { + common.ErrorResp(c, err, 500) + } else { + common.SuccessResp(c) + } + }) g.POST("/clear_done", func(c *gin.Context) { manager.ClearDone() common.SuccessResp(c) }) + g.POST("/clear_succeeded", func(c *gin.Context) { + manager.ClearSucceeded() + common.SuccessResp(c) + }) } func SetupTaskRoute(g *gin.RouterGroup) {