Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be able to use official topology #787

Merged
1 commit merged into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading