@@ -1720,14 +1720,45 @@ func (d *NASStorageDriver) reconcileNodeAccessForBackendPolicy(
17201720}
17211721
17221722func (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