Skip to content

Commit

Permalink
Add OS topology key to node segments map
Browse files Browse the repository at this point in the history
Signed-off-by: Eddie Torres <[email protected]>
  • Loading branch information
torredil committed Feb 28, 2024
1 parent 7f19755 commit 380c4d4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ const (

WellKnownTopologyKey = "topology.kubernetes.io/zone"
// DEPRECATED Use the WellKnownTopologyKey instead
TopologyKey = "topology." + DriverName + "/zone"
TopologyKey = "topology." + DriverName + "/zone"
OSTopologyKey = "kubernetes.io/os"
)

type Driver struct {
Expand Down
3 changes: 3 additions & 0 deletions pkg/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -587,10 +588,12 @@ func (d *nodeService) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoReque
klog.V(4).InfoS("NodeGetInfo: called", "args", *req)

zone := d.metadata.GetAvailabilityZone()
osType := runtime.GOOS

segments := map[string]string{
TopologyKey: zone,
WellKnownTopologyKey: zone,
OSTopologyKey: osType,
}

outpostArn := d.metadata.GetOutpostArn()
Expand Down
4 changes: 4 additions & 0 deletions pkg/driver/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"io/fs"
"os"
"reflect"
"runtime"
"strings"
"testing"

Expand Down Expand Up @@ -2334,6 +2335,9 @@ func TestNodeGetInfo(t *testing.T) {
if at.Segments[WellKnownTopologyKey] != tc.availabilityZone {
t.Fatalf("Expected (well-known) topology %q, got %q", tc.availabilityZone, at.Segments[WellKnownTopologyKey])
}
if at.Segments[OSTopologyKey] != runtime.GOOS {
t.Fatalf("Expected os topology %q, got %q", runtime.GOOS, at.Segments[OSTopologyKey])
}

if at.Segments[AwsAccountIDKey] != tc.outpostArn.AccountID {
t.Fatalf("Expected AwsAccountId %q, got %q", tc.outpostArn.AccountID, at.Segments[AwsAccountIDKey])
Expand Down

0 comments on commit 380c4d4

Please sign in to comment.