Skip to content

Commit

Permalink
change sort function naming. Adjust set quota value assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
VoigtS committed Dec 6, 2024
1 parent 2bbde92 commit b0512ee
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion internal/plugins/capacity_liquid.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ 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 := SortMapKeys(p.LiquidServiceInfo.Resources)
resourceNames := SortedMapKeys(p.LiquidServiceInfo.Resources)
var errs []error
for _, resourceName := range resourceNames {
perAZ := resp.Resources[resourceName].PerAZ
Expand Down
6 changes: 2 additions & 4 deletions internal/plugins/liquid.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ 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 := SortMapKeys(p.LiquidServiceInfo.Resources)
resourceNames := SortedMapKeys(p.LiquidServiceInfo.Resources)
var errs []error
for _, resourceName := range resourceNames {
perAZ := resp.Resources[resourceName].PerAZ
Expand Down Expand Up @@ -198,9 +198,7 @@ func (p *liquidQuotaPlugin) SetQuota(ctx context.Context, project core.KeystoneP
req := liquid.ServiceQuotaRequest{

Check failure on line 198 in internal/plugins/liquid.go

View workflow job for this annotation

GitHub Actions / Checks

ineffectual assignment to req (ineffassign)
Resources: make(map[liquid.ResourceName]liquid.ResourceQuotaRequest, len(quotaReq)),
}
for resName, request := range quotaReq {
req.Resources[resName] = liquid.ResourceQuotaRequest{Quota: request.Quota, PerAZ: request.PerAZ}
}
req = liquid.ServiceQuotaRequest{Resources: quotaReq}
if p.LiquidServiceInfo.QuotaUpdateNeedsProjectMetadata {
req.ProjectMetadata = project.ForLiquid()
}
Expand Down
6 changes: 3 additions & 3 deletions internal/plugins/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func p2u64(val uint64) *uint64 {
return &val
}

func SortMapKeys[M map[K]V, K ~string, V any](mapToSort M) []K {
func SortedMapKeys[M map[K]V, K ~string, V any](mapToSort M) []K {
sortedKeys := slices.Collect(maps.Keys(mapToSort))
slices.Sort(sortedKeys)
return sortedKeys
Expand All @@ -43,7 +43,7 @@ func CheckResourceTopologies(serviceInfo liquid.ServiceInfo) (err error) {
var errs []error
resources := serviceInfo.Resources

resourceNames := SortMapKeys(resources)
resourceNames := SortedMapKeys(resources)
for _, resourceName := range resourceNames {
topology := resources[resourceName].Topology
if topology == "" {
Expand Down Expand Up @@ -84,6 +84,6 @@ func MatchLiquidReportToTopology[V any](perAZReport map[liquid.AvailabilityZone]
return
}

reportedAZs := SortMapKeys(perAZReport)
reportedAZs := SortedMapKeys(perAZReport)
return fmt.Errorf("scrape with topology type: %s returned AZs: %v", topology, reportedAZs)
}
2 changes: 1 addition & 1 deletion internal/test/plugins/quota_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func (p *GenericQuotaPlugin) Scrape(ctx context.Context, project core.KeystonePr

if len(p.ReportedAZs) > 0 {
var errs []error
resourceNames := plugins.SortMapKeys(p.LiquidServiceInfo.Resources)
resourceNames := plugins.SortedMapKeys(p.LiquidServiceInfo.Resources)
for _, resourceName := range resourceNames {
topology := p.LiquidServiceInfo.Resources[resourceName].Topology
err := plugins.MatchLiquidReportToTopology(p.ReportedAZs, topology)
Expand Down

0 comments on commit b0512ee

Please sign in to comment.