diff --git a/plugin/migration/api.go b/plugin/migration/api.go index 9e19c942..cbb1dbe9 100644 --- a/plugin/migration/api.go +++ b/plugin/migration/api.go @@ -227,6 +227,10 @@ func (h *APIHandler) startDataMigration(w http.ResponseWriter, req *http.Request h.WriteError(w, fmt.Sprintf("task [%s] not found", taskID), http.StatusInternalServerError) return } + if obj.Status == task2.StatusComplete { + h.WriteError(w, fmt.Sprintf("task [%s] completed, can't start anymore", taskID), http.StatusInternalServerError) + return + } obj.Status = task2.StatusReady err = orm.Update(nil, &obj) @@ -284,6 +288,12 @@ func (h *APIHandler) stopDataMigrationTask(w http.ResponseWriter, req *http.Requ }, http.StatusNotFound) return } + if task2.IsEnded(obj.Status) { + h.WriteJSON(w, util.MapStr{ + "success": true, + }, 200) + return + } //query all pipeline task(scroll/bulk_indexing) and then stop it err = stopPipelineTasks(id) if err != nil {