Skip to content

Commit

Permalink
use new function liquid.NormalizeAZ() where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
majewsky committed Dec 18, 2024
1 parent a1e6cdd commit 2e7a30d
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/prometheus/client_golang v1.20.5
github.com/prometheus/common v0.61.0
github.com/rs/cors v1.11.1
github.com/sapcc/go-api-declarations v1.13.1
github.com/sapcc/go-api-declarations v1.13.2
github.com/sapcc/go-bits v0.0.0-20241213102058-cb5d877d1274
go.uber.org/automaxprocs v1.6.0
gopkg.in/yaml.v2 v2.4.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA=
github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/sapcc/go-api-declarations v1.13.1 h1:rovCnLscnoZaIZPWhohSYHzwwYjOnCPsRw3zwtu4tLI=
github.com/sapcc/go-api-declarations v1.13.1/go.mod h1:83R3hTANhuRXt/pXDby37IJetw8l7DG41s33Tp9NXxI=
github.com/sapcc/go-api-declarations v1.13.2 h1:dPYYsjwKGObSAm6+K+dYCiLQWunYuWkywlZnuXfjsmk=
github.com/sapcc/go-api-declarations v1.13.2/go.mod h1:83R3hTANhuRXt/pXDby37IJetw8l7DG41s33Tp9NXxI=
github.com/sapcc/go-bits v0.0.0-20241213102058-cb5d877d1274 h1:ja3KsSLFDrjtPLqFt6qnPMxMnTuseP5+JpP0IshJSe4=
github.com/sapcc/go-bits v0.0.0-20241213102058-cb5d877d1274/go.mod h1:hhH7PgcPklzzJdx1zMhv3KiMEnoCZV+pnapPRcgI7wk=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
Expand Down
11 changes: 2 additions & 9 deletions internal/liquids/cinder/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"context"
"encoding/json"
"fmt"
"slices"

"github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/quotasets"
"github.com/gophercloud/gophercloud/v2/openstack/blockstorage/v3/snapshots"
Expand Down Expand Up @@ -106,10 +105,7 @@ func (l *Logic) collectVolumeSubresources(ctx context.Context, projectUUID strin
}

for _, volume := range vols {
az := liquid.AvailabilityZone(volume.AvailabilityZone)
if !slices.Contains(allAZs, az) {
az = liquid.AvailabilityZoneUnknown
}
az := liquid.NormalizeAZ(volume.AvailabilityZone, allAZs)
vt := VolumeType(volume.VolumeType)
placementForVolumeUUID[volume.ID] = VolumePlacement{vt, az}

Expand Down Expand Up @@ -171,10 +167,7 @@ func (l *Logic) collectSnapshotSubresources(ctx context.Context, projectUUID str
snapshot.VolumeID, snapshot.ID, projectUUID, err)
}
vt := VolumeType(volume.VolumeType)
az := liquid.AvailabilityZone(volume.AvailabilityZone)
if !slices.Contains(allAZs, az) {
az = liquid.AvailabilityZoneUnknown
}
az := liquid.NormalizeAZ(volume.AvailabilityZone, allAZs)
placement = VolumePlacement{vt, az}
}

Expand Down
4 changes: 2 additions & 2 deletions internal/liquids/ironic/capacity.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func (l *Logic) ScanCapacity(ctx context.Context, req liquid.ServiceCapacityRequ
// so we can use this to establish an AZ-to-node relationship.
azForResourceProviderUUID := make(map[string]liquid.AvailabilityZone)
for _, aggr := range allAggregates {
az := liquid.AvailabilityZone(aggr.AvailabilityZone)
if az == "" || !slices.Contains(req.AllAZs, az) {
az := liquid.NormalizeAZ(aggr.AvailabilityZone, req.AllAZs)
if az == liquid.AvailabilityZoneUnknown {
// we are only interested in aggregates that are connected to AZs that we know
continue
}
Expand Down
6 changes: 1 addition & 5 deletions internal/liquids/ironic/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package ironic
import (
"context"
"fmt"
"slices"

"github.com/gophercloud/gophercloud/v2/openstack/compute/v2/limits"
"github.com/gophercloud/gophercloud/v2/openstack/compute/v2/quotasets"
Expand Down Expand Up @@ -122,10 +121,7 @@ func (l *Logic) addInstanceToReport(ctx context.Context, resources map[liquid.Re
}

// count this instance for the AZ breakdown
az := liquid.AvailabilityZone(instance.AvailabilityZone)
if !slices.Contains(allAZs, az) {
az = liquid.AvailabilityZoneUnknown
}
az := liquid.NormalizeAZ(instance.AvailabilityZone, allAZs)
resReport.AddLocalizedUsage(az, 1)

// add subresource if requested
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ github.com/rabbitmq/amqp091-go
## explicit; go 1.13
github.com/rs/cors
github.com/rs/cors/internal
# github.com/sapcc/go-api-declarations v1.13.1
# github.com/sapcc/go-api-declarations v1.13.2
## explicit; go 1.21
github.com/sapcc/go-api-declarations/bininfo
github.com/sapcc/go-api-declarations/cadf
Expand Down

0 comments on commit 2e7a30d

Please sign in to comment.