Skip to content

Commit

Permalink
Fix multi array zone info (#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvgenyUglov authored Dec 10, 2024
1 parent 200c699 commit 6e3737c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
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

0 comments on commit 6e3737c

Please sign in to comment.