Skip to content

Commit

Permalink
scrape: fix error collector
Browse files Browse the repository at this point in the history
  • Loading branch information
VoigtS committed Dec 5, 2024
1 parent 95e45d5 commit a5e846c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions internal/plugins/capacity_liquid.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ func (p *liquidCapacityPlugin) Scrape(ctx context.Context, backchannel core.Capa
p.LiquidServiceType, p.LiquidServiceInfo.Version, resp.InfoVersion)
}
resourceNames := SortMapKeys(p.LiquidServiceInfo.Resources)
var errs []error
for _, resourceName := range resourceNames {
errs := []error{}
perAZ := resp.Resources[liquid.ResourceName(resourceName)].PerAZ
toplogy := p.LiquidServiceInfo.Resources[liquid.ResourceName(resourceName)].Topology
err := MatchLiquidReportToTopology(perAZ, toplogy)
if err != nil {
errs = append(errs, fmt.Errorf("service: %s, resource: %s: %w", p.ServiceType, resourceName, err))
}
if len(errs) > 0 {
return nil, nil, errors.Join(errs...)
}
}
if len(errs) > 0 {
return nil, nil, errors.Join(errs...)
}

resultInService := make(map[liquid.ResourceName]core.PerAZ[core.CapacityData], len(p.LiquidServiceInfo.Resources))
Expand Down
8 changes: 4 additions & 4 deletions internal/plugins/liquid.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,17 @@ func (p *liquidQuotaPlugin) Scrape(ctx context.Context, project core.KeystonePro
p.LiquidServiceType, p.LiquidServiceInfo.Version, resp.InfoVersion)
}
resourceNames := SortMapKeys(p.LiquidServiceInfo.Resources)
var errs []error
for _, resourceName := range resourceNames {
errs := []error{}
perAZ := resp.Resources[liquid.ResourceName(resourceName)].PerAZ
toplogy := p.LiquidServiceInfo.Resources[liquid.ResourceName(resourceName)].Topology
err := MatchLiquidReportToTopology(perAZ, toplogy)
if err != nil {
errs = append(errs, fmt.Errorf("service: %s, resource: %s: %w", p.ServiceType, resourceName, err))
}
if len(errs) > 0 {
return nil, nil, errors.Join(errs...)
}
}
if len(errs) > 0 {
return nil, nil, errors.Join(errs...)
}

result = make(map[liquid.ResourceName]core.ResourceData, len(p.LiquidServiceInfo.Resources))
Expand Down
2 changes: 1 addition & 1 deletion internal/test/plugins/quota_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (p *GenericQuotaPlugin) Scrape(ctx context.Context, project core.KeystonePr
}

if len(p.ReportedAZs) > 0 {
errs := []error{}
var errs []error
resourceNames := plugins.SortMapKeys(p.LiquidServiceInfo.Resources)
for _, resourceName := range resourceNames {
toplogy := p.LiquidServiceInfo.Resources[liquid.ResourceName(resourceName)].Topology
Expand Down

0 comments on commit a5e846c

Please sign in to comment.