Skip to content

Commit 85abe59

Browse files
committed
feat: created code in ReconcileVolumeNodeAccess.
added EnableCustomExportPolicySettings where needed
1 parent b53e272 commit 85abe59

3 files changed

Lines changed: 39 additions & 3 deletions

File tree

core/concurrent_core.go

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

15971597
// Update volume cache on backend.
15981598
backend.Volumes().Store(vol.Config.Name, vol)
1599+
1600+
// Update volume based access policy when backend reloads.
1601+
backend.ReconcileVolumeNodeAccess(ctx, vol.Config, volResult.Nodes)
15991602
}
16001603

16011604
// update the backend cache

storage_drivers/ontap/ontap_common.go

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

474474
// Rule does not exist, so create it
475475
if !ruleFound {
476+
// Create Export Rule
476477
if err = clientAPI.ExportRuleCreate(ctx, policyName, desiredRule, config.NASType); err != nil {
477478
// Check if error is that the export policy rule already exist error
478479
if errors.IsAlreadyExistsError(err) {
@@ -628,6 +629,7 @@ func reconcileExportPolicyRules(
628629
}
629630
deleted++
630631
}
632+
631633
return nil
632634
}
633635

storage_drivers/ontap/ontap_nas.go

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

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

17381769
return nil
17391770
}

0 commit comments

Comments
 (0)