@@ -1726,14 +1726,45 @@ func (d *NASStorageDriver) reconcileNodeAccessForBackendPolicy(
17261726}
17271727
17281728func (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