From b68496a82a96cad486364d1412be888408c7a986 Mon Sep 17 00:00:00 2001 From: Liujian <824010343@qq.com> Date: Thu, 17 Apr 2025 16:20:17 +0800 Subject: [PATCH] Fix: Issue where API portal's service list fails to retrieve when Influxdb is not initialized --- module/application-authorization/iml.go | 4 +++- module/catalogue/iml.go | 10 +++++++++- module/mcp/iml.go | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/module/application-authorization/iml.go b/module/application-authorization/iml.go index d14ec5ae..583b17ab 100644 --- a/module/application-authorization/iml.go +++ b/module/application-authorization/iml.go @@ -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 diff --git a/module/catalogue/iml.go b/module/catalogue/iml.go index b36f6958..cbea8773 100644 --- a/module/catalogue/iml.go +++ b/module/catalogue/iml.go @@ -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 } diff --git a/module/mcp/iml.go b/module/mcp/iml.go index 8ae2ac23..6a88ffd6 100644 --- a/module/mcp/iml.go +++ b/module/mcp/iml.go @@ -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) }