避免project未找到直接返回err

This commit is contained in:
屈轩
2019-01-22 16:17:10 +08:00
parent 1eec7ce094
commit 3e4b8fed08
+5
View File
@@ -10,6 +10,8 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/consts"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/util/httputils"
)
type STenantCacheManager struct {
@@ -81,6 +83,9 @@ func (manager *STenantCacheManager) fetchTenantFromKeystone(ctx context.Context,
s := auth.GetAdminSession(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
}