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 wg.Done()
defer close(sch) defer close(sch)
done := make(chan bool) done := make(chan bool)
storage := &collector.Usage{}
go func() { go func() {


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


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


done <- true done <- true
}() }()


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


done <- true done <- true
}() }()


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


Loading…
Cancel
Save