From 58641bdf22943eef993fd0218b62cfc5e9dcda16 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julian=20T=C3=B6lle?= <julian.toelle@hetzner-cloud.de>
Date: Fri, 25 Nov 2022 10:27:54 +0100
Subject: [PATCH] fix: invalid topology label on new volumes #333 (#334)

Revert the topology segment label used for new volumes to
`csi.hetzner.cloud/location`. Adding the new label was a mistake and leads
to incompatibility with the CSI spec (and Nomad).

We plan to fully revert the changes, but that will require user intervention
to fix all volumes created with the new label. By changing the label used
on new volumes, we can limit the amount of volumes that need to be fixed
for users that already upgraded to v2.0.0.

See issue #333 for details.
---
 driver/controller.go      | 2 +-
 driver/controller_test.go | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/driver/controller.go b/driver/controller.go
index f42c29e..f2da5ea 100644
--- a/driver/controller.go
+++ b/driver/controller.go
@@ -94,7 +94,7 @@ func (s *ControllerService) CreateVolume(ctx context.Context, req *proto.CreateV
 			AccessibleTopology: []*proto.Topology{
 				{
 					Segments: map[string]string{
-						TopologySegmentLocation: volume.Location,
+						TopologySegmentLocationLegacy: volume.Location,
 					},
 				},
 			},
diff --git a/driver/controller_test.go b/driver/controller_test.go
index 7b14042..1abdb35 100644
--- a/driver/controller_test.go
+++ b/driver/controller_test.go
@@ -91,7 +91,7 @@ func TestControllerServiceCreateVolume(t *testing.T) {
 	}
 	if len(resp.Volume.AccessibleTopology) == 1 {
 		top := resp.Volume.AccessibleTopology[0]
-		if loc := top.Segments[TopologySegmentLocation]; loc != "testloc" {
+		if loc := top.Segments[TopologySegmentLocationLegacy]; loc != "testloc" {
 			t.Errorf("unexpected location segment in topology: %s", loc)
 		}
 	} else {
@@ -146,7 +146,7 @@ func TestControllerServiceCreateVolumeWithLocation(t *testing.T) {
 	}
 	if len(resp.Volume.AccessibleTopology) == 1 {
 		top := resp.Volume.AccessibleTopology[0]
-		if loc := top.Segments[TopologySegmentLocation]; loc != "explicit" {
+		if loc := top.Segments[TopologySegmentLocationLegacy]; loc != "explicit" {
 			t.Errorf("unexpected location segment in topology: %s", loc)
 		}
 	} else {
-- 
GitLab