Skip to content

Commit 04eccf1

Browse files
committed
feat: created code in ReconcileVolumeNodeAccess.
added EnableCustomExportPolicySettings where needed
1 parent ebb1d8c commit 04eccf1

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

core/concurrent_core.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,9 @@ func (o *ConcurrentTridentOrchestrator) updateBackendVolumes(ctx context.Context
15841584

15851585
// Update volume cache on backend.
15861586
backend.Volumes().Store(vol.Config.Name, vol)
1587+
1588+
// Update volume based access policy when backend reloads.
1589+
backend.ReconcileVolumeNodeAccess(ctx, vol.Config, volResult.Nodes)
15871590
}
15881591

15891592
// update the backend cache

storage_drivers/ontap/ontap_common.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ func ensureNodeAccessForPolicy(
452452

453453
// Rule does not exist, so create it
454454
if !ruleFound {
455+
// Create Export Rule
455456
if err = clientAPI.ExportRuleCreate(ctx, policyName, desiredRule, config.NASType); err != nil {
456457
// Check if error is that the export policy rule already exist error
457458
if errors.IsAlreadyExistsError(err) {
@@ -604,6 +605,7 @@ func reconcileExportPolicyRules(
604605
}
605606
deleted++
606607
}
608+
607609
return nil
608610
}
609611

storage_drivers/ontap/ontap_nas.go

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,14 +1720,45 @@ func (d *NASStorageDriver) reconcileNodeAccessForBackendPolicy(
17201720
}
17211721

17221722
func (d *NASStorageDriver) ReconcileVolumeNodeAccess(
1723-
ctx context.Context, _ *storage.VolumeConfig, _ []*models.Node,
1723+
ctx context.Context, volConfig *storage.VolumeConfig, nodes []*models.Node,
17241724
) error {
1725+
1726+
if !d.Config.AutoExportPolicy {
1727+
return nil
1728+
}
1729+
1730+
policyName := volConfig.ExportPolicy
1731+
17251732
fields := LogFields{
17261733
"Method": "ReconcileVolumeNodeAccess",
17271734
"Type": "NASStorageDriver",
1735+
"policyName": policyName,
1736+
}
1737+
1738+
Logc(ctx).WithFields(fields).Debug(">>>>>> ReconcileVolumeNodeAccess")
1739+
defer Logc(ctx).Debug("<<<<<< ReconcileVolumeNodeAccess")
1740+
1741+
1742+
// Ensure the export policy exists. If it doesn't, create it.
1743+
// This also handles the case where it might have been deleted out-of-band.
1744+
if err := ensureExportPolicyExists(ctx, policyName, d.API); err != nil {
1745+
Logc(ctx).WithError(err).WithField("ExportPolicy", policyName).Error("Error ensuring export policy exists during volume node access reconciliation.")
1746+
return fmt.Errorf("error ensuring export policy %s exists: %v", policyName, err)
1747+
}
1748+
1749+
desiredRules, err := getDesiredExportPolicyRules(ctx, nodes, &d.Config)
1750+
if err != nil {
1751+
err = fmt.Errorf("unable to determine desired export policy rules; %v", err)
1752+
Logc(ctx).Error(err)
1753+
return err
1754+
}
1755+
1756+
err = reconcileExportPolicyRules(ctx, policyName, desiredRules, d.API, &d.Config)
1757+
if err != nil {
1758+
err = fmt.Errorf("unabled to reconcile export policy rules; %v", err)
1759+
Logc(ctx).WithField("ExportPolicy", policyName).Error(err)
1760+
return err
17281761
}
1729-
Logd(ctx, d.Name(), d.Config.DebugTraceFlags["method"]).WithFields(fields).Trace(">>>> ReconcileVolumeNodeAccess")
1730-
defer Logd(ctx, d.Name(), d.Config.DebugTraceFlags["method"]).WithFields(fields).Trace("<<<< ReconcileVolumeNodeAccess")
17311762

17321763
return nil
17331764
}

0 commit comments

Comments
 (0)