Skip to content

Commit

Permalink
fix(taskman): use admin token if task userCred token expired
Browse files Browse the repository at this point in the history
Use admin credential token if task cached userCred token expired
  • Loading branch information
Qiu Jian committed Dec 19, 2020
1 parent 4e864a7 commit 70d2e5c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/cloudcommon/db/taskman/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/httperrors"
"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/rbacutils"
)
Expand Down Expand Up @@ -815,7 +816,11 @@ func (self *STask) GetObjects() []db.IStandaloneModel {
}

func (task *STask) GetTaskRequestHeader() http.Header {
header := mcclient.GetTokenHeaders(task.GetUserCred())
userCred := task.GetUserCred()
if !userCred.IsValid() {
userCred = auth.AdminCredential()
}
header := mcclient.GetTokenHeaders(userCred)
header.Set(mcclient.TASK_ID, task.GetTaskId())
return header
}
Expand Down

0 comments on commit 70d2e5c

Please sign in to comment.