Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check missing resource reports before checking toplogy #621

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions internal/plugins/capacity_liquid.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
}
Expand Down
27 changes: 14 additions & 13 deletions internal/plugins/liquid.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
Loading