diff --git a/pkg/cloudcommon/db/tenantcache.go b/pkg/cloudcommon/db/tenantcache.go index c16394a2d6..ee42bc40fc 100644 --- a/pkg/cloudcommon/db/tenantcache.go +++ b/pkg/cloudcommon/db/tenantcache.go @@ -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 }