diff --git a/internal/plugins/capacity_liquid.go b/internal/plugins/capacity_liquid.go index b487cf45..76f60b65 100644 --- a/internal/plugins/capacity_liquid.go +++ b/internal/plugins/capacity_liquid.go @@ -94,19 +94,6 @@ func (p *liquidCapacityPlugin) Scrape(ctx context.Context, backchannel core.Capa logg.Fatal("ServiceInfo version for %s changed from %d to %d; restarting now to reload ServiceInfo...", p.LiquidServiceType, p.LiquidServiceInfo.Version, resp.InfoVersion) } - resourceNames := SortedMapKeys(p.LiquidServiceInfo.Resources) - var errs []error - for _, resourceName := range resourceNames { - perAZ := resp.Resources[resourceName].PerAZ - topology := p.LiquidServiceInfo.Resources[resourceName].Topology - err := MatchLiquidReportToTopology(perAZ, topology) - if err != nil { - errs = append(errs, fmt.Errorf("resource: %s: %w", resourceName, err)) - } - } - if len(errs) > 0 { - return nil, nil, errors.Join(errs...) - } resultInService := make(map[liquid.ResourceName]core.PerAZ[core.CapacityData], len(p.LiquidServiceInfo.Resources)) for resName, resInfo := range p.LiquidServiceInfo.Resources { @@ -128,6 +115,21 @@ func (p *liquidCapacityPlugin) Scrape(ctx context.Context, backchannel core.Capa } resultInService[resName] = resData } + + resourceNames := SortedMapKeys(p.LiquidServiceInfo.Resources) + var errs []error + for _, resourceName := range resourceNames { + perAZ := resp.Resources[resourceName].PerAZ + topology := p.LiquidServiceInfo.Resources[resourceName].Topology + err := MatchLiquidReportToTopology(perAZ, topology) + if err != nil { + errs = append(errs, fmt.Errorf("resource: %s: %w", resourceName, err)) + } + } + if len(errs) > 0 { + return nil, nil, errors.Join(errs...) + } + result = map[db.ServiceType]map[liquid.ResourceName]core.PerAZ[core.CapacityData]{ p.ServiceType: resultInService, } diff --git a/internal/plugins/liquid.go b/internal/plugins/liquid.go index c6105de5..13a08872 100644 --- a/internal/plugins/liquid.go +++ b/internal/plugins/liquid.go @@ -123,19 +123,6 @@ func (p *liquidQuotaPlugin) Scrape(ctx context.Context, project core.KeystonePro logg.Fatal("ServiceInfo version for %s changed from %d to %d; restarting now to reload ServiceInfo...", p.LiquidServiceType, p.LiquidServiceInfo.Version, resp.InfoVersion) } - resourceNames := SortedMapKeys(p.LiquidServiceInfo.Resources) - var errs []error - for _, resourceName := range resourceNames { - perAZ := resp.Resources[resourceName].PerAZ - topology := p.LiquidServiceInfo.Resources[resourceName].Topology - err := MatchLiquidReportToTopology(perAZ, topology) - if err != nil { - errs = append(errs, fmt.Errorf("resource: %s: %w", resourceName, err)) - } - } - if len(errs) > 0 { - return nil, nil, errors.Join(errs...) - } result = make(map[liquid.ResourceName]core.ResourceData, len(p.LiquidServiceInfo.Resources)) for resName, resInfo := range p.LiquidServiceInfo.Resources { @@ -167,6 +154,20 @@ func (p *liquidQuotaPlugin) Scrape(ctx context.Context, project core.KeystonePro result[resName] = resData } + resourceNames := SortedMapKeys(p.LiquidServiceInfo.Resources) + var errs []error + for _, resourceName := range resourceNames { + perAZ := resp.Resources[resourceName].PerAZ + topology := p.LiquidServiceInfo.Resources[resourceName].Topology + err := MatchLiquidReportToTopology(perAZ, topology) + if err != nil { + errs = append(errs, fmt.Errorf("resource: %s: %w", resourceName, err)) + } + } + if len(errs) > 0 { + return nil, nil, errors.Join(errs...) + } + serializedMetrics, err = liquidSerializeMetrics(p.LiquidServiceInfo.UsageMetricFamilies, resp.Metrics) if err != nil { return nil, nil, fmt.Errorf("while serializing metrics: %w", err)