fix(region): task panic (#15345)

This commit is contained in:
屈轩
2022-11-11 19:51:37 +08:00
committed by GitHub
parent 66f01d043b
commit 079be4492d
2 changed files with 22 additions and 1 deletions
+20 -1
View File
@@ -32,9 +32,11 @@ import (
"yunion.io/x/pkg/util/reflectutils"
"yunion.io/x/pkg/util/stringutils"
"yunion.io/x/pkg/util/timeutils"
"yunion.io/x/pkg/util/version"
"yunion.io/x/pkg/utils"
"yunion.io/x/sqlchemy"
"yunion.io/x/onecloud/pkg/apis"
"yunion.io/x/onecloud/pkg/appctx"
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
@@ -43,6 +45,7 @@ import (
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/auth"
"yunion.io/x/onecloud/pkg/util/httputils"
"yunion.io/x/onecloud/pkg/util/logclient"
"yunion.io/x/onecloud/pkg/util/rbacutils"
)
@@ -549,9 +552,25 @@ func execITask(taskValue reflect.Value, task *STask, odata jsonutils.JSONObject,
SetStageFailedFuncValue.Call(
[]reflect.Value{
reflect.ValueOf(ctx),
reflect.ValueOf(fmt.Sprintf("%v", r)),
reflect.ValueOf(jsonutils.NewString(fmt.Sprintf("%v", r))),
},
)
obj, err := objResManager.FetchById(task.ObjId)
if err != nil {
return
}
statusObj, ok := obj.(db.IStatusStandaloneModel)
if ok {
db.StatusBaseSetStatus(statusObj, task.GetUserCred(), apis.STATUS_UNKNOWN, fmt.Sprintf("%v", r))
}
notes := map[string]interface{}{
"Stack": string(debug.Stack()),
"Version": version.GetShortString(),
"Task": task.TaskName,
"Stage": stageName,
"Message": fmt.Sprintf("%v", r),
}
logclient.AddSimpleActionLog(obj, logclient.ACT_PANIC, notes, task.GetUserCred(), false)
}
}()
+2
View File
@@ -235,4 +235,6 @@ const (
ACT_CONSOLE = "console"
ACT_WEBSSH = "webssh"
ACT_SET_USER_PASSWORD = "set_user_password"
ACT_PANIC = "panic"
)