Merge pull request #960 in YUNIONIO/onecloud from ~QUXUAN/onecloud:hotfix/qx-conflict-2.5.0 to release/2.5.0

* commit 'b9dd5052ca8db90cbb1f9897350e9a5c56089c20':
  避免project未找到直接返回err
This commit is contained in:
邱剑
2019-01-22 16:30:35 +08:00
+6
View File
@@ -8,9 +8,12 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/consts"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/auth"
"yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/util/httputils"
)
type STenantCacheManager struct {
@@ -82,6 +85,9 @@ func (manager *STenantCacheManager) fetchTenantFromKeystone(ctx context.Context,
s := auth.GetAdminSession(ctx, consts.GetRegion(), "v1")
tenant, err := modules.Projects.Get(s, idStr, nil)
if err != nil {
if je, ok := err.(*httputils.JSONClientError); ok && je.Code == 404 {
return nil, sql.ErrNoRows
}
log.Errorf("fetch project fail %s", err)
return nil, err
}