@@ -73,6 +73,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
73
73
var podName , podNamespace , podUID string
74
74
var targetPath string
75
75
var mounted bool
76
+ var isRemountRequest bool
76
77
errorReason := internalerrors .FailedToMount
77
78
rotationEnabled := ns .rotationConfig .enabled
78
79
@@ -81,7 +82,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
81
82
// if there is an error at any stage during node publish volume and if the path
82
83
// has already been mounted, unmount the target path so the next time kubelet calls
83
84
// again for mount, entire node publish volume is retried
84
- if targetPath != "" && mounted {
85
+ if targetPath != "" && mounted && ! isRemountRequest {
85
86
klog .InfoS ("unmounting target path as node publish volume failed" , "targetPath" , targetPath , "pod" , klog.ObjectRef {Namespace : podNamespace , Name : podName })
86
87
if unmountErr := ns .mounter .Unmount (targetPath ); unmountErr != nil {
87
88
klog .ErrorS (unmountErr , "failed to unmounting target path" )
@@ -142,6 +143,9 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
142
143
return nil , status .Errorf (codes .Internal , "failed to check if target path %s is mount point, err: %v" , targetPath , err )
143
144
}
144
145
}
146
+ // If it is mounted, it means this is not the first time mount request for this path.
147
+ isRemountRequest = mounted
148
+
145
149
// If rotation is not enabled, don't remount the already mounted secrets.
146
150
if ! rotationEnabled && mounted {
147
151
klog .InfoS ("target path is already mounted" , "targetPath" , targetPath , "pod" , klog.ObjectRef {Namespace : podNamespace , Name : podName })
@@ -237,7 +241,11 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
237
241
mounted = true
238
242
var objectVersions map [string ]string
239
243
if objectVersions , errorReason , err = ns .mountSecretsStoreObjectContent (ctx , providerName , string (parametersStr ), string (secretStr ), targetPath , string (permissionStr ), podName ); err != nil {
240
- klog .ErrorS (err , "failed to mount secrets store object content" , "pod" , klog.ObjectRef {Namespace : podNamespace , Name : podName })
244
+ klog .ErrorS (err , "failed to mount secrets store object content" , "pod" , klog.ObjectRef {Namespace : podNamespace , Name : podName }, "isRemountRequest" , isRemountRequest )
245
+ if isRemountRequest {
246
+ // Mask error until fix available for https://github.com/kubernetes/kubernetes/issues/121271
247
+ return & csi.NodePublishVolumeResponse {}, nil
248
+ }
241
249
return nil , fmt .Errorf ("failed to mount secrets store objects for pod %s/%s, err: %w" , podNamespace , podName , err )
242
250
}
243
251
@@ -246,6 +254,11 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
246
254
// the pod with same name (pods created by statefulsets) is moved to a different node and the old SPCPS
247
255
// has not yet been garbage collected.
248
256
if err = createOrUpdateSecretProviderClassPodStatus (ctx , ns .client , ns .reader , podName , podNamespace , podUID , secretProviderClass , targetPath , ns .nodeID , true , objectVersions ); err != nil {
257
+ klog .ErrorS (err , "failed to create/update spcps" , "pod" , klog.ObjectRef {Namespace : podNamespace , Name : podName }, "isRemountRequest" , isRemountRequest )
258
+ if isRemountRequest {
259
+ // Mask error until fix available for https://github.com/kubernetes/kubernetes/issues/121271
260
+ return & csi.NodePublishVolumeResponse {}, nil
261
+ }
249
262
return nil , fmt .Errorf ("failed to create secret provider class pod status for pod %s/%s, err: %w" , podNamespace , podName , err )
250
263
}
251
264
0 commit comments