@@ -80,8 +80,9 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
80
80
defer func () {
81
81
if err != nil {
82
82
// if there is an error at any stage during node publish volume and if the path
83
- // has already been mounted, unmount the target path so the next time kubelet calls
83
+ // has already been mounted if the rotation is disabled , unmount the target path so the next time kubelet calls
84
84
// again for mount, entire node publish volume is retried
85
+ // If the rotation is enabled the target path won't be unmounted just the next call will try to mount the content.
85
86
if targetPath != "" && mounted && ! isRemountRequest {
86
87
klog .InfoS ("unmounting target path as node publish volume failed" , "targetPath" , targetPath , "pod" , klog.ObjectRef {Namespace : podNamespace , Name : podName })
87
88
if unmountErr := ns .mounter .Unmount (targetPath ); unmountErr != nil {
@@ -120,16 +121,6 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
120
121
podNamespace = attrib [CSIPodNamespace ]
121
122
podUID = attrib [CSIPodUID ]
122
123
123
- if ns .rotationConfig .enabled {
124
- lastModificationTime , err := ns .getLastUpdateTime (targetPath )
125
- if err != nil {
126
- klog .InfoS ("could not find last modification time for targetpath" , targetPath , "error" , err )
127
- } else if startTime .Before (lastModificationTime .Add (ns .rotationConfig .rotationPollInterval )) {
128
- // if next rotation is not yet due, then skip the mount operation
129
- return & csi.NodePublishVolumeResponse {}, nil
130
- }
131
- }
132
-
133
124
mounted , err = ns .ensureMountPoint (targetPath )
134
125
if err != nil {
135
126
// kubelet will not create the CSI NodePublishVolume target directory in 1.20+, in accordance with the CSI specification.
@@ -152,6 +143,16 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
152
143
return & csi.NodePublishVolumeResponse {}, nil
153
144
}
154
145
146
+ if rotationEnabled {
147
+ lastModificationTime , err := ns .getLastUpdateTime (targetPath )
148
+ if err != nil {
149
+ klog .InfoS ("could not find last modification time for targetpath" , targetPath , "error" , err )
150
+ } else if startTime .Before (lastModificationTime .Add (ns .rotationConfig .rotationPollInterval )) {
151
+ // if next rotation is not yet due, then skip the mount operation
152
+ return & csi.NodePublishVolumeResponse {}, nil
153
+ }
154
+ }
155
+
155
156
klog .V (2 ).InfoS ("node publish volume" , "target" , targetPath , "volumeId" , volumeID , "mount flags" , mountFlags )
156
157
157
158
if isMockProvider (providerName ) {
@@ -200,7 +201,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
200
201
// and send it to the provider in the parameters.
201
202
if parameters [CSIPodServiceAccountTokens ] == "" {
202
203
// Inject pod service account token into volume attributes
203
- klog .ErrorS (err , "csi.storage.k8s.io/serviceAccount.tokens is not populated, set RequiresRepublish " )
204
+ klog .Info (err , "csi.storage.k8s.io/serviceAccount.tokens is not populated" )
204
205
}
205
206
206
207
// ensure it's read-only
0 commit comments