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

Retrieve zone information from multi array secret #819

Merged
merged 1 commit into from
Dec 10, 2024
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
11 changes: 4 additions & 7 deletions pkg/drivers/powerflex.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,7 @@ func ExtractZonesFromSecret(ctx context.Context, kube client.Client, namespace s
type StorageArrayConfig struct {
SystemID string `json:"systemId"`
Zone struct {
Name string `json:"name"`
LabelKey string `json:"labelKey"`
Name string `json:"name"`
} `json:"zone"`
}

Expand All @@ -383,11 +382,9 @@ func ExtractZonesFromSecret(ctx context.Context, kube client.Client, namespace s
if configParam.SystemID == "" {
return nil, fmt.Errorf("invalid value for SystemID")
}
if configParam.Zone.LabelKey != "" {
if configParam.Zone.Name != "" {
zonesMapData[configParam.Zone.LabelKey] = configParam.Zone.Name
log.Infof("Zoning information configured for systemID %s: %v ", configParam.SystemID, zonesMapData)
}
if configParam.Zone.Name != "" {
zonesMapData[configParam.SystemID] = configParam.Zone.Name
log.Infof("Zoning information configured for systemID %s: %v ", configParam.SystemID, zonesMapData)
} else {
log.Info("Zoning information not found in the array config. Continue with topology-unaware driver installation mode")
return zonesMapData, nil
Expand Down
36 changes: 35 additions & 1 deletion pkg/drivers/powerflex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,26 @@ func TestExtractZonesFromSecret(t *testing.T) {
zone:
name: "US-EAST"
labelKey: "zone.csi-vxflexos.dellemc.com"
`
zoneDataWithMultiArray := `
- username: "admin"
password: "password"
systemID: "2b11bb111111bb1b"
endpoint: "https://127.0.0.2"
skipCertificateValidation: true
mdm: "10.0.0.3,10.0.0.4"
zone:
name: "ZONE-1"
labelKey: "zone.csi-vxflexos.dellemc.com"
- username: "admin"
password: "password"
systemID: "1a99aa999999aa9a"
endpoint: "https://127.0.0.1"
skipCertificateValidation: true
mdm: "10.0.0.5,10.0.0.6"
zone:
name: "ZONE-2"
labelKey: "zone.csi-vxflexos.dellemc.com"
`
dataWithoutZone := `
- username: "admin"
Expand All @@ -243,7 +263,21 @@ func TestExtractZonesFromSecret(t *testing.T) {
}

client := fake.NewClientBuilder().WithObjects(secret).Build()
return client, map[string]string{"zone.csi-vxflexos.dellemc.com": "US-EAST"}, "vxflexos-config", false
return client, map[string]string{"2b11bb111111bb1b": "US-EAST"}, "vxflexos-config", false
},
"success with zone and multi array": func() (client.WithWatch, map[string]string, string, bool) {
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "vxflexos-config",
Namespace: "vxflexos",
},
Data: map[string][]byte{
"config": []byte(zoneDataWithMultiArray),
},
}

client := fake.NewClientBuilder().WithObjects(secret).Build()
return client, map[string]string{"2b11bb111111bb1b": "ZONE-1", "1a99aa999999aa9a": "ZONE-2"}, "vxflexos-config", false
},
"success no zone": func() (client.WithWatch, map[string]string, string, bool) {
secret := &corev1.Secret{
Expand Down
Loading