Skip to content

Commit 0122cb5

Browse files
committed
Remove changes to getZoneFromSegment, no longer required
1 parent 57c3e4a commit 0122cb5

File tree

2 files changed

+5
-71
lines changed

2 files changed

+5
-71
lines changed

pkg/gce-pd-csi-driver/controller.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -2321,11 +2321,9 @@ func getZonesFromTopology(topList []*csi.Topology) ([]string, error) {
23212321
func getZoneFromSegment(seg map[string]string) (string, error) {
23222322
var zone string
23232323
for k, v := range seg {
2324-
switch {
2325-
case k == common.TopologyKeyZone:
2324+
switch k {
2325+
case common.TopologyKeyZone:
23262326
zone = v
2327-
case common.IsGKETopologyLabel(k):
2328-
continue
23292327
default:
23302328
return "", fmt.Errorf("topology segment has unknown key %v", k)
23312329
}

pkg/gce-pd-csi-driver/controller_test.go

+3-67
Original file line numberDiff line numberDiff line change
@@ -1376,49 +1376,6 @@ func TestCreateVolumeArguments(t *testing.T) {
13761376
},
13771377
enableDiskTopology: true,
13781378
},
1379-
{
1380-
// Desired as the disk type label should match the `type` parameter,
1381-
// not the accessibility requirements.
1382-
name: "success: disk topology labels in accessibility requirements have no effect",
1383-
req: &csi.CreateVolumeRequest{
1384-
Name: "test-name",
1385-
CapacityRange: stdCapRange,
1386-
VolumeCapabilities: stdVolCaps,
1387-
Parameters: map[string]string{"type": stdDiskType},
1388-
AccessibilityRequirements: &csi.TopologyRequirement{
1389-
Requisite: []*csi.Topology{
1390-
{
1391-
Segments: map[string]string{
1392-
common.TopologyKeyZone: "topology-zone3",
1393-
common.TopologyLabelKey("another-disk-type"): "true",
1394-
},
1395-
},
1396-
},
1397-
Preferred: []*csi.Topology{
1398-
{
1399-
Segments: map[string]string{
1400-
common.TopologyKeyZone: "topology-zone3",
1401-
common.TopologyLabelKey("another-disk-type"): "true",
1402-
},
1403-
},
1404-
},
1405-
},
1406-
},
1407-
expVol: &csi.Volume{
1408-
CapacityBytes: common.GbToBytes(20),
1409-
VolumeId: fmt.Sprintf("projects/%s/zones/topology-zone3/disks/%s", project, name),
1410-
VolumeContext: nil,
1411-
AccessibleTopology: []*csi.Topology{
1412-
{
1413-
Segments: map[string]string{
1414-
common.TopologyKeyZone: "topology-zone3",
1415-
common.TopologyLabelKey(stdDiskType): "true",
1416-
},
1417-
},
1418-
},
1419-
},
1420-
enableDiskTopology: true,
1421-
},
14221379
}
14231380

14241381
// Run test cases
@@ -3984,22 +3941,13 @@ func TestCreateVolumeRandomRequisiteTopology(t *testing.T) {
39843941
AccessibilityRequirements: &csi.TopologyRequirement{
39853942
Requisite: []*csi.Topology{
39863943
{
3987-
Segments: map[string]string{
3988-
common.TopologyKeyZone: "topology-zone3",
3989-
common.TopologyLabelKey("disk-1"): "true",
3990-
},
3944+
Segments: map[string]string{common.TopologyKeyZone: "topology-zone3"},
39913945
},
39923946
{
3993-
Segments: map[string]string{
3994-
common.TopologyKeyZone: "topology-zone1",
3995-
common.TopologyLabelKey("disk-2"): "true",
3996-
},
3947+
Segments: map[string]string{common.TopologyKeyZone: "topology-zone1"},
39973948
},
39983949
{
3999-
Segments: map[string]string{
4000-
common.TopologyKeyZone: "topology-zone2",
4001-
common.TopologyLabelKey("disk-3"): "true",
4002-
},
3950+
Segments: map[string]string{common.TopologyKeyZone: "topology-zone2"},
40033951
},
40043952
},
40053953
},
@@ -4462,18 +4410,6 @@ func TestGetZonesFromTopology(t *testing.T) {
44624410
name: "success: no topology",
44634411
expZones: sets.NewString(),
44644412
},
4465-
{
4466-
name: "success: disk type label is ignored without causing an error",
4467-
topology: []*csi.Topology{
4468-
{
4469-
Segments: map[string]string{
4470-
common.TopologyKeyZone: "test-zone",
4471-
common.TopologyLabelKey("disk-type"): "true",
4472-
},
4473-
},
4474-
},
4475-
expZones: sets.NewString([]string{"test-zone"}...),
4476-
},
44774413
}
44784414
for _, tc := range testCases {
44794415
t.Logf("test case: %s", tc.name)

0 commit comments

Comments
 (0)