Skip to content

Commit

Permalink
refactor(inventory): ensure GPU interfaces are lowercase (#225)
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian authored Mar 29, 2024
1 parent f83ea24 commit 0fa3077
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cluster/kube/operators/clients/inventory/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func tryAdjustGPU(rp *inventoryV1.GPU, res *types.GPU, sparams *crd.SchedulerPar
continue
}

if (attr.Interface != "") && (attr.Interface != info.Interface) {
if (attr.Interface != "") && (attr.Interface != ctypes.FilterGPUInterface(info.Interface)) {
continue
}
}
Expand Down
13 changes: 13 additions & 0 deletions cluster/types/v1beta3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"context"
"io"
"strings"

inventoryV1 "github.com/akash-network/akash-api/go/inventory/v1"
mtypes "github.com/akash-network/akash-api/go/node/market/v1beta4"
Expand Down Expand Up @@ -160,3 +161,15 @@ type HostnameServiceClient interface {
CanReserveHostnames(hostnames []string, ownerAddr sdktypes.Address) error
PrepareHostnamesForTransfer(ctx context.Context, hostnames []string, leaseID mtypes.LeaseID) error
}

// FilterGPUInterface ensures interface values are always lower case
// generalizes sxm* to sxm
func FilterGPUInterface(val string) string {
val = strings.ToLower(val)

if strings.HasPrefix(val, "sxm") {
val = "sxm"
}

return val
}
3 changes: 2 additions & 1 deletion operator/inventory/node-discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
v1 "github.com/akash-network/akash-api/go/inventory/v1"

"github.com/akash-network/provider/cluster/kube/builder"
ctypes "github.com/akash-network/provider/cluster/types/v1beta3"
"github.com/akash-network/provider/tools/fromctx"
)

Expand Down Expand Up @@ -813,7 +814,7 @@ func generateLabels(cfg Config, knode *corev1.Node, node v1.Node, sc storageClas
}

if info.Interface != "" {
key := fmt.Sprintf("%s.interface.%s", key, info.Interface)
key := fmt.Sprintf("%s.interface.%s", key, ctypes.FilterGPUInterface(info.Interface))
if val, exists := res[key]; exists {
nval, _ := strconv.ParseUint(val, 10, 32)
nval++
Expand Down

0 comments on commit 0fa3077

Please sign in to comment.