diff --git a/pkg/compute/models/cloudaccounts.go b/pkg/compute/models/cloudaccounts.go index 3a74932d0a8..29ee0ae385b 100644 --- a/pkg/compute/models/cloudaccounts.go +++ b/pkg/compute/models/cloudaccounts.go @@ -3085,7 +3085,7 @@ func (account *SCloudaccount) PerformProjectMapping(ctx context.Context, userCre if len(input.ProjectId) == 0 && !input.AutoCreateProjectForProvider { return nil, errors.Wrap(httperrors.ErrInputParameter, "empty project_id") } - if input.AutoCreateProject { + if input.AutoCreateProject || input.AutoCreateProjectForProvider { t, err := db.TenantCacheManager.FetchTenantByIdOrNameInDomain(ctx, input.ProjectId, account.DomainId) if err != nil { return nil, errors.Wrap(err, "FetchTenantByIdOrNameInDomain") @@ -3093,14 +3093,6 @@ func (account *SCloudaccount) PerformProjectMapping(ctx context.Context, userCre input.ProjectId = t.Id } - if input.AutoCreateProjectForProvider { - t, err := db.TenantCacheManager.FetchTenantByIdOrNameInDomain(ctx, "system", account.DomainId) - if err != nil { - return nil, errors.Wrap(err, "FetchTenantByIdOrNameInDomain") - } - input.ProjectId = t.Id - } - _, err := db.Update(account, func() error { account.ProjectId = input.ProjectId account.AutoCreateProject = input.AutoCreateProject