fix: try resolve tenant by project id first (#19277)

Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
Jian Qiu
2024-01-17 00:28:30 +08:00
committed by GitHub
parent 8c50a52fe0
commit a42ce1792e
+8
View File
@@ -191,6 +191,14 @@ func (t *STenant) IsExpired() bool {
}
func (manager *STenantCacheManager) FetchTenantByIdOrNameInDomain(ctx context.Context, idStr string, domainId string) (*STenant, error) {
if !stringutils2.IsUtf8(idStr) {
t, err := manager.FetchTenantById(ctx, idStr)
if t != nil {
return t, nil
} else if err != nil && errors.Cause(err) != sql.ErrNoRows {
return nil, errors.Wrap(err, "FetchTenantById")
}
}
return manager.fetchTenant(ctx, idStr, domainId, false, false, func(q *sqlchemy.SQuery) *sqlchemy.SQuery {
if stringutils2.IsUtf8(idStr) {
return q.Equals("name", idStr)