fix: refresh after created and deleted migration task
This commit is contained in:
parent
f36e088f4e
commit
50c3539cb0
|
@ -56,7 +56,10 @@ func CreateTask(config *migration_model.ClusterComparisonTaskConfig, creator *rb
|
|||
return nil, fmt.Errorf("repeat invalid: %v", err)
|
||||
}
|
||||
|
||||
err = orm.Create(nil, t)
|
||||
ctx := &orm.Context{
|
||||
Refresh: "wait_for",
|
||||
}
|
||||
err = orm.Create(ctx, t)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -56,7 +56,10 @@ func CreateTask(config *migration_model.ClusterMigrationTaskConfig, creator *rba
|
|||
return nil, fmt.Errorf("repeat invalid: %v", err)
|
||||
}
|
||||
|
||||
err = orm.Create(nil, t)
|
||||
ctx := &orm.Context{
|
||||
Refresh: "wait_for",
|
||||
}
|
||||
err = orm.Create(ctx, t)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -206,7 +206,10 @@ func (h *APIHandler) startTask(w http.ResponseWriter, req *http.Request, ps http
|
|||
}
|
||||
}
|
||||
|
||||
err = orm.Update(nil, &obj)
|
||||
ctx := &orm.Context{
|
||||
Refresh: "wait_for",
|
||||
}
|
||||
err = orm.Update(ctx, &obj)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
h.WriteError(w, err.Error(), http.StatusInternalServerError)
|
||||
|
@ -264,12 +267,19 @@ func (h *APIHandler) deleteTask(w http.ResponseWriter, req *http.Request, ps htt
|
|||
h.WriteError(w, fmt.Sprintf("can not delete task [%s] with status [%s]", obj.ID, obj.Status), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
ctx := &orm.Context{
|
||||
Refresh: "wait_for",
|
||||
}
|
||||
err = orm.Delete(ctx, &obj)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
h.WriteError(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
q := util.MapStr{
|
||||
"query": util.MapStr{
|
||||
"bool": util.MapStr{
|
||||
"minimum_should_match": 1,
|
||||
"should": []util.MapStr{
|
||||
"must": []util.MapStr{
|
||||
{
|
||||
"term": util.MapStr{
|
||||
"parent_id": util.MapStr{
|
||||
|
@ -277,22 +287,13 @@ func (h *APIHandler) deleteTask(w http.ResponseWriter, req *http.Request, ps htt
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"term": util.MapStr{
|
||||
"id": util.MapStr{
|
||||
"value": id,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
err = orm.DeleteBy(&obj, util.MustToJSONBytes(q))
|
||||
if err != nil {
|
||||
h.WriteError(w, err.Error(), http.StatusInternalServerError)
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
h.WriteJSON(w, util.MapStr{
|
||||
|
@ -337,7 +338,10 @@ func (h *APIHandler) resumeTask(w http.ResponseWriter, req *http.Request, ps htt
|
|||
}
|
||||
|
||||
lastRepeatingChild.Metadata.Labels["repeat_triggered"] = false
|
||||
err = orm.Update(nil, lastRepeatingChild)
|
||||
ctx := &orm.Context{
|
||||
Refresh: "wait_for",
|
||||
}
|
||||
err = orm.Update(ctx, lastRepeatingChild)
|
||||
if err != nil {
|
||||
log.Errorf("failed to update last child, err: %v", err)
|
||||
h.WriteError(w, err.Error(), http.StatusInternalServerError)
|
||||
|
|
Loading…
Reference in New Issue