Skip to content

Commit

Permalink
allow unspecified topology only for the one remaining legacy case
Browse files Browse the repository at this point in the history
  • Loading branch information
majewsky committed Dec 12, 2024
1 parent 8acf2b3 commit 2bc3adc
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions internal/plugins/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"slices"

"github.com/sapcc/go-api-declarations/liquid"
"github.com/sapcc/go-bits/logg"
)

func p2u64(val uint64) *uint64 {
Expand All @@ -40,21 +39,23 @@ func SortedMapKeys[M map[K]V, K ~string, V any](mapToSort M) []K {
}

func CheckResourceTopologies(serviceInfo liquid.ServiceInfo) (err error) {
// TODO: remove this special case once liquid-ceph has rolled out their topology support
// (if you come across this, it's probably time; ping Stefan M. to ask for confirmation)
for resName, resInfo := range serviceInfo.Resources {
if resName == "objectstore_region_3_hdd_capacity" && resInfo.Topology == "" {
resInfo.Topology = liquid.FlatResourceTopology
serviceInfo.Resources[resName] = resInfo
}
}

var errs []error
resources := serviceInfo.Resources

resourceNames := SortedMapKeys(resources)
for _, resourceName := range resourceNames {
resInfo := resources[resourceName]
if resInfo.Topology == "" {
// several algorithms inside Limes depend on a topology being chosen, so we have to pick a default for now
// TODO: make this a fatal error once liquid-ceph has rolled out their Topology patch
logg.Error("missing topology on resource: %s (assuming %q)", resourceName, liquid.FlatResourceTopology)
resInfo.Topology = liquid.FlatResourceTopology
resources[resourceName] = resInfo
}
if !resInfo.Topology.IsValid() {
errs = append(errs, fmt.Errorf("invalid topology: %s on resource: %s", resInfo.Topology, resourceName))
topology := resources[resourceName].Topology
if !topology.IsValid() {
errs = append(errs, fmt.Errorf("invalid topology: %s on resource: %s", topology, resourceName))
}
}
if len(errs) > 0 {
Expand Down

0 comments on commit 2bc3adc

Please sign in to comment.