Skip to content

Commit 9d1f5f0

Browse files
authored
Fix for duplicate export rule deletion
1 parent 8f11e51 commit 9d1f5f0

File tree

13 files changed

+556
-175
lines changed

13 files changed

+556
-175
lines changed

mocks/mock_storage_drivers/mock_ontap/mock_api.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mocks/mock_utils/mock_fcp/mock_fcp_client.go

Lines changed: 28 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mocks/mock_utils/mock_fcp/mock_fcp_os_client.go

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mocks/mock_utils/mock_fcp/mock_reconcile_utils.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

storage_drivers/ontap/api/abstraction.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type OntapAPI interface {
5858
ExportPolicyExists(ctx context.Context, policyName string) (bool, error)
5959
ExportRuleCreate(ctx context.Context, policyName, desiredPolicyRule, nasProtocol string) error
6060
ExportRuleDestroy(ctx context.Context, policyName string, ruleIndex int) error
61-
ExportRuleList(ctx context.Context, policyName string) (map[string]int, error)
61+
ExportRuleList(ctx context.Context, policyName string) (map[int]string, error)
6262

6363
FlexgroupCreate(ctx context.Context, volume Volume) error
6464
FlexgroupExists(ctx context.Context, volumeName string) (bool, error)

storage_drivers/ontap/api/abstraction_rest.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,13 +1222,13 @@ func (d OntapAPIREST) ExportPolicyExists(ctx context.Context, policyName string)
12221222
return true, nil
12231223
}
12241224

1225-
func (d OntapAPIREST) ExportRuleList(ctx context.Context, policyName string) (map[string]int, error) {
1225+
func (d OntapAPIREST) ExportRuleList(ctx context.Context, policyName string) (map[int]string, error) {
12261226
ruleListResponse, err := d.api.ExportRuleList(ctx, policyName)
12271227
if err != nil {
12281228
return nil, fmt.Errorf("error listing export policy rules; %v", err)
12291229
}
12301230

1231-
rules := make(map[string]int)
1231+
rules := make(map[int]string)
12321232
if ruleListResponse != nil &&
12331233
ruleListResponse.Payload != nil &&
12341234
ruleListResponse.Payload.NumRecords != nil &&
@@ -1238,7 +1238,13 @@ func (d OntapAPIREST) ExportRuleList(ctx context.Context, policyName string) (ma
12381238
for _, rule := range exportRuleList {
12391239
for _, client := range rule.ExportRuleInlineClients {
12401240
if client.Match != nil && rule.Index != nil {
1241-
rules[*client.Match] = int(*rule.Index)
1241+
index := int(*rule.Index)
1242+
match := *client.Match
1243+
if existing, ok := rules[index]; ok && existing != "" {
1244+
rules[index] = fmt.Sprintf("%s,%s", existing, match)
1245+
} else {
1246+
rules[index] = match
1247+
}
12421248
}
12431249
}
12441250
}

0 commit comments

Comments
 (0)