mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #10968 from ioito/automated-cherry-pick-of-#10967-upstream-release-3.7
Automated cherry pick of #10967: fix(keystone): avoid panic when call logclient
This commit is contained in:
@@ -278,7 +278,7 @@ func GetTokenString() string {
|
||||
}
|
||||
|
||||
func IsAuthed() bool {
|
||||
return manager.isAuthed()
|
||||
return manager != nil && manager.isAuthed()
|
||||
}
|
||||
|
||||
func Client() *mcclient.Client {
|
||||
|
||||
@@ -161,7 +161,11 @@ func addLog(model IObject, action string, iNotes interface{}, userCred mcclient.
|
||||
logentry.Add(jsonutils.NewString(notes), "notes")
|
||||
|
||||
logclientWorkerMan.Run(func() {
|
||||
s := DefaultSessionGenerator(context.Background(), auth.AdminCredential(), "", "")
|
||||
cred := userCred
|
||||
if auth.IsAuthed() {
|
||||
cred = auth.AdminCredential()
|
||||
}
|
||||
s := DefaultSessionGenerator(context.Background(), cred, "", "")
|
||||
_, err := api.Create(s, logentry)
|
||||
if err != nil {
|
||||
log.Errorf("create action log %s failed %s", logentry, err)
|
||||
|
||||
Reference in New Issue
Block a user