Skip to content

Commit

Permalink
Add topology.kubernetes.io/zone if topology.bsu.outscale.com/zone not…
Browse files Browse the repository at this point in the history
… found
  • Loading branch information
vincentBaer committed Sep 20, 2023
1 parent 8be720e commit f361a69
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
8 changes: 8 additions & 0 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,20 @@ func pickAvailabilityZone(requirement *csi.TopologyRequirement) string {
if exists {
return zone
}
zone, exists = topology.GetSegments()[TopologyK8sKey]
if exists {
return zone
}
}
for _, topology := range requirement.GetRequisite() {
zone, exists := topology.GetSegments()[TopologyKey]
if exists {
return zone
}
zone, exists = topology.GetSegments()[TopologyK8sKey]
if exists {
return zone
}
}
return ""
}
Expand Down
22 changes: 22 additions & 0 deletions pkg/driver/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,28 @@ func TestPickAvailabilityZone(t *testing.T) {
},
expZone: expZone,
},
{
name: "Pick from requisite topologyK8sKey",
requirement: &csi.TopologyRequirement{
Requisite: []*csi.Topology{
{
Segments: map[string]string{TopologyK8sKey: expZone},
},
},
},
expZone: expZone,
},
{
name: "Pick from multi requisites",
requirement: &csi.TopologyRequirement{
Requisite: []*csi.Topology{
{
Segments: map[string]string{TopologyKey: expZone, TopologyK8sKey: expZone},
},
},
},
expZone: expZone,
},
{
name: "Pick from empty topology",
requirement: &csi.TopologyRequirement{
Expand Down
5 changes: 3 additions & 2 deletions pkg/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ const (
)

const (
DriverName = "bsu.csi.outscale.com"
TopologyKey = "topology." + DriverName + "/zone"
DriverName = "bsu.csi.outscale.com"
TopologyKey = "topology." + DriverName + "/zone"
TopologyK8sKey = "topology.kubernetes.io/zone"
)

type Driver struct {
Expand Down

0 comments on commit f361a69

Please sign in to comment.