From 380c4d414b5f515f9a230542b5f17cfaa729c712 Mon Sep 17 00:00:00 2001 From: Eddie Torres Date: Wed, 28 Feb 2024 19:34:08 +0000 Subject: [PATCH] Add OS topology key to node segments map Signed-off-by: Eddie Torres --- pkg/driver/driver.go | 3 ++- pkg/driver/node.go | 3 +++ pkg/driver/node_test.go | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/driver/driver.go b/pkg/driver/driver.go index 626e31c259..71a40a2f64 100644 --- a/pkg/driver/driver.go +++ b/pkg/driver/driver.go @@ -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 { diff --git a/pkg/driver/node.go b/pkg/driver/node.go index b5f50ef0cd..d88c3de3fa 100644 --- a/pkg/driver/node.go +++ b/pkg/driver/node.go @@ -22,6 +22,7 @@ import ( "fmt" "os" "path/filepath" + "runtime" "strings" "time" @@ -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() diff --git a/pkg/driver/node_test.go b/pkg/driver/node_test.go index 0fcf67b504..2e043aec3b 100644 --- a/pkg/driver/node_test.go +++ b/pkg/driver/node_test.go @@ -26,6 +26,7 @@ import ( "io/fs" "os" "reflect" + "runtime" "strings" "testing" @@ -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])