Skip to content

Commit

Permalink
fix microservice failed to find cluster name
Browse files Browse the repository at this point in the history
  • Loading branch information
chengjoey committed Apr 8, 2024
1 parent 2d3bcf5 commit 39adac6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
24 changes: 24 additions & 0 deletions internal/apps/msp/tenant/db/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,30 @@ func (db *MSPTenantDB) QueryTenantByProjectID(projectID string) ([]*MSPTenant, e
return tenants, nil
}

func (db *MSPTenantDB) QueryTenantHaveTMC(projectID string) ([]*MSPTenant, error) {
var tenants []*MSPTenant
err := db.Raw(`select msp.id as id,
msp.type as type,
msp.related_project_id as related_project_id,
msp.created_at as created_at,
msp.updated_at as updated_at,
msp.is_deleted as is_deleted
from msp_tenant as msp
left join tb_tmc_instance_tenant as tmc on msp.id = tmc.tenant_group
where msp.is_deleted = 0
and msp.related_project_id = ?
and tmc.is_deleted = 'N'
and tmc.az != ''
group by msp.id`, projectID).Find(&tenants).Error
if err == gorm.ErrRecordNotFound {
return nil, nil
}
if err != nil {
return nil, err
}
return tenants, nil
}

func (db *MSPTenantDB) DeleteTenantByTenantID(tenantId string) (*MSPTenant, error) {
tenant, err := db.QueryTenant(tenantId)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/apps/msp/tenant/project/project.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (s *projectService) GetProjectList(ctx context.Context, projectIDs []string
if project == nil {
continue
}
if project.Relationship == nil || len(project.Relationship) == 0 {
if len(project.Relationship) == 0 {
continue
}

Expand Down Expand Up @@ -325,7 +325,7 @@ func (s *projectService) GetProjectInfo(lang i18n.LanguageCodes, id string) (*pb
return nil, nil
}
project := s.convertToProject(projectDB)
tenants, err := s.MSPTenantDB.QueryTenantByProjectID(id)
tenants, err := s.MSPTenantDB.QueryTenantHaveTMC(id)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 39adac6

Please sign in to comment.