Fix: Issue where API portal's service list fails to retrieve when Influxdb is not initialized

This commit is contained in:
Liujian
2025-04-17 16:20:17 +08:00
parent c7c3e8033b
commit b68496a82a
3 changed files with 15 additions and 2 deletions
+3 -1
View File
@@ -200,11 +200,13 @@ func (i *imlAuthorizationModule) initGateway(ctx context.Context, partitionId st
}
func (i *imlAuthorizationModule) online(ctx context.Context, s *service.Service) error {
clusters, err := i.clusterService.List(ctx)
if err != nil {
return err
}
if len(clusters) < 1 {
return nil
}
authorizations, err := i.authorizationService.ListByApp(ctx, s.Id)
if err != nil {
return err
+9 -1
View File
@@ -181,8 +181,16 @@ func (i *imlCatalogueModule) genCommonWheres(ctx context.Context, clusterIds ...
}
func (i *imlCatalogueModule) ProviderStatistics(ctx context.Context, start, end time.Time, serviceIds ...string) (map[string]int64, error) {
// 判断是否配置influxdb
clusterId := cluster.DefaultClusterID
_, err := i.clusterService.Get(ctx, clusterId)
_, err := i.monitorService.Get(ctx, clusterId)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return make(map[string]int64), nil
}
return nil, err
}
_, err = i.clusterService.Get(ctx, clusterId)
if err != nil {
return nil, err
}
+3
View File
@@ -8,6 +8,7 @@ import (
"io"
"net/http"
"net/url"
"strconv"
"strings"
"time"
@@ -268,6 +269,8 @@ func (i *imlMcpModule) Invoke(ctx context.Context, req mcp.CallToolRequest) (*mc
for _, value := range v {
queryParam.Add(k, value)
}
case float64:
queryParam.Add(k, strconv.FormatFloat(v, 'e', -1, 64))
default:
return nil, fmt.Errorf("invalid query param type: %T", v)
}