Skip to content

Commit

Permalink
change UsageData quota attribute to a pointer type
Browse files Browse the repository at this point in the history
  • Loading branch information
VoigtS committed Dec 5, 2024
1 parent 022983d commit 463e9ea
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion internal/collector/scrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (c *Collector) writeResourceScrapeResult(dbDomain db.Domain, dbProject db.P
// set AZ backend quota.
resInfo := c.Cluster.InfoForResource(srv.Type, res.Name)
if resInfo.Topology == liquid.AZSeparatedResourceTopology && resInfo.HasQuota {
azRes.BackendQuota = &data.Quota
azRes.BackendQuota = data.Quota
}
// reset backendQuota entries for topology changes
if resInfo.Topology != liquid.AZSeparatedResourceTopology {
Expand Down
2 changes: 1 addition & 1 deletion internal/core/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (r ResourceData) AddLocalizedUsage(az limes.AvailabilityZone, usage uint64)
// UsageData contains usage data for a single project resource.
// It appears in type ResourceData.
type UsageData struct {
Quota int64
Quota *int64
Usage uint64
PhysicalUsage *uint64 // only supported by some plugins
Subresources []any // only if supported by plugin and enabled in config
Expand Down
2 changes: 1 addition & 1 deletion internal/plugins/liquid.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (p *liquidQuotaPlugin) Scrape(ctx context.Context, project core.KeystonePro
Subresources: castSliceToAny(azReport.Subresources),
}
if resInfo.Topology == liquid.AZSeparatedResourceTopology && azReport.Quota != nil {
resData.UsageData[az].Quota = *azReport.Quota
resData.UsageData[az].Quota = azReport.Quota
}
}

Expand Down
10 changes: 6 additions & 4 deletions internal/test/plugins/quota_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,21 @@ type GenericQuotaPlugin struct {
// Init implements the core.QuotaPlugin interface.
func (p *GenericQuotaPlugin) Init(ctx context.Context, provider *gophercloud.ProviderClient, eo gophercloud.EndpointOpts, serviceType db.ServiceType) error {
p.ServiceType = serviceType
thingsAZQuota := int64(21)
capacityAZQuota := int64(50)
p.StaticResourceData = map[liquid.ResourceName]*core.ResourceData{
"things": {
Quota: 42,
UsageData: core.PerAZ[core.UsageData]{
"az-one": {Usage: 2, Quota: 21},
"az-two": {Usage: 2, Quota: 21},
"az-one": {Usage: 2, Quota: &thingsAZQuota},
"az-two": {Usage: 2, Quota: &thingsAZQuota},
},
},
"capacity": {
Quota: 100,
UsageData: core.PerAZ[core.UsageData]{
"az-one": {Usage: 0, Quota: 50},
"az-two": {Usage: 0, Quota: 50},
"az-one": {Usage: 0, Quota: &capacityAZQuota},
"az-two": {Usage: 0, Quota: &capacityAZQuota},
},
},
}
Expand Down

0 comments on commit 463e9ea

Please sign in to comment.