Browse Source

fix shuguang getresourcespecs issue

pull/410/head
tzwang 9 months ago
parent
commit
18e1766eb5
1 changed files with 6 additions and 7 deletions
  1. +6
    -7
      internal/storeLink/shuguangai.go

+ 6
- 7
internal/storeLink/shuguangai.go View File

@@ -1296,7 +1296,7 @@ func (s *ShuguangAi) GetResourceSpecs(ctx context.Context) (*collector.ResourceS
defer wg.Done()
defer close(sch)
done := make(chan bool)
storage := &collector.Usage{}
go func() {

diskReq := &hpcAC.ParaStorQuotaReq{}
@@ -1308,7 +1308,7 @@ func (s *ShuguangAi) GetResourceSpecs(ctx context.Context) (*collector.ResourceS

totalStorage := common.RoundFloat(diskResp.Data[0].Threshold, 0)
availStorage := common.RoundFloat((diskResp.Data[0].Threshold - diskResp.Data[0].Usage), 0)
storage := &collector.Usage{}
storage.Type = STORAGE
storage.Name = DISK
storage.Total = &collector.UnitValue{
@@ -1319,14 +1319,13 @@ func (s *ShuguangAi) GetResourceSpecs(ctx context.Context) (*collector.ResourceS
Unit: GIGABYTE,
Value: availStorage,
}
sch <- storage

done <- true
}()

select {
case <-done:
return
sch <- storage
case <-time.After(time.Duration(timeout) * time.Second):
return
}
@@ -1336,7 +1335,7 @@ func (s *ShuguangAi) GetResourceSpecs(ctx context.Context) (*collector.ResourceS
go func() {
defer uwg.Done()
done := make(chan bool)
cres := &collector.ClusterResource{}
go func() {
userReq := &hpcAC.GetUserInfoReq{}
userinfo, err := s.aCRpc.GetUserInfo(ctx, userReq)
@@ -1351,14 +1350,14 @@ func (s *ShuguangAi) GetResourceSpecs(ctx context.Context) (*collector.ResourceS
Unit: RMB,
Value: balance,
}
cresCh <- &collector.ClusterResource{Resource: bal}
cres.Resource = bal

done <- true
}()

select {
case <-done:
return
cresCh <- cres
case <-time.After(time.Duration(timeout) * time.Second):
return
}


Loading…
Cancel
Save